Browse Source

Adding email-sending test script

Joe Ceresini 7 years ago
parent
commit
ec38e81d08
1 changed files with 28 additions and 0 deletions
  1. 28 0
      test-scripts/send-test-email.py

+ 28 - 0
test-scripts/send-test-email.py

@@ -0,0 +1,28 @@
+import smtplib
+import sys
+
+if len(sys.argv) != 4:
+	print "Usage %s [from] [to] [subject]"
+	sys.exit(10)
+
+from_addr=sys.argv[1]
+to_addr=sys.argv[2]
+subject=sys.argv[3]
+
+# Import the email modules we'll need
+from email.mime.text import MIMEText
+
+# Create a text/plain message
+msg = MIMEText("Test email")
+
+# me == the sender's email address
+# you == the recipient's email address
+msg['Subject'] = subject
+msg['From'] = from_addr
+msg['To'] = to_addr
+
+# Send the message via our own SMTP server, but don't include the
+# envelope header.
+s = smtplib.SMTP('localhost')
+s.sendmail(from_addr, to_addr, msg.as_string())
+s.quit()