Explorar o código

Adding email-sending test script

Joe Ceresini %!s(int64=7) %!d(string=hai) anos
pai
achega
ec38e81d08
Modificáronse 1 ficheiros con 28 adicións e 0 borrados
  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()