From 26e6a205735dced344dc93285fd436eeabf80529 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Thu, 31 Jan 2013 13:51:56 -0700 Subject: [PATCH] add tokens for netre --- doc/2013-02-TF5/course-mail.txt | 7 ++++++- doc/2013-02-TF5/spam.py | 29 +++++++++++++++++++++-------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/doc/2013-02-TF5/course-mail.txt b/doc/2013-02-TF5/course-mail.txt index ac55d71..3b863b3 100644 --- a/doc/2013-02-TF5/course-mail.txt +++ b/doc/2013-02-TF5/course-mail.txt @@ -1,6 +1,11 @@ From: The Tracer FIRE Registration Fairy To: RCPT -Subject: Tracer FIRE: Your Course Assignment +Subject: Tracer FIRE: Your Course Assignment (repeat email) + +This is a repeat email of your course assignment. Some people didn't +recieve their assignment on Monday. This should not contain any new +information if you've already seen your course assignment. + Your course assignment is: diff --git a/doc/2013-02-TF5/spam.py b/doc/2013-02-TF5/spam.py index 768203f..f84d3bda 100755 --- a/doc/2013-02-TF5/spam.py +++ b/doc/2013-02-TF5/spam.py @@ -1,14 +1,27 @@ #! /usr/bin/python3 import smtplib +import sys + +courses = { + "net": "Network Archaeology", + "mal": "Malware Reverse-Engineering", + "hst": "Host Forensics", + "icc": "Incident Coordination", + "nil": "None", +} smtpd = smtplib.SMTP("mail.lanl.gov") -template = open("hubs-mail.txt").read() - -for line in open("assignments.txt"): - course, email = line.strip().split() - - print(email) - msg = template.replace("RCPT", email) - smtpd.sendmail("neale@lanl.gov", [email], msg) +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)