moth/doc/2013-02-TF5/spam.py

28 lines
604 B
Python
Raw Normal View History

#! /usr/bin/python3
import smtplib
2013-01-31 13:51:56 -07:00
import sys
2013-01-31 13:51:56 -07:00
courses = {
"net": "Network Archaeology",
"mal": "Malware Reverse-Engineering",
"hst": "Host Forensics",
"icc": "Incident Coordination",
"nil": "None",
}
2013-01-31 13:51:56 -07:00
smtpd = smtplib.SMTP("mail.lanl.gov")
2013-01-31 13:51:56 -07:00
template = sys.stdin.read()
if 'RCPT' not in template:
print("Pass the template on stdin.")
else:
for line in open("assignments.txt"):
course, email = line.strip().split()
coursename = courses[course]
print(email)
msg = template.replace("RCPT", email).replace("COURSE", coursename)
smtpd.sendmail("neale@lanl.gov", [email], msg)
#print(msg)