community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1749550 - /comdev/reporter.apache.org/trunk/scripts/sendmail.py
Date Tue, 21 Jun 2016 14:56:58 GMT
Author: sebb
Date: Tue Jun 21 14:56:58 2016
New Revision: 1749550

URL: http://svn.apache.org/viewvc?rev=1749550&view=rev
Log:
Allow code to work with a recipient list

Modified:
    comdev/reporter.apache.org/trunk/scripts/sendmail.py

Modified: comdev/reporter.apache.org/trunk/scripts/sendmail.py
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/scripts/sendmail.py?rev=1749550&r1=1749549&r2=1749550&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/scripts/sendmail.py (original)
+++ comdev/reporter.apache.org/trunk/scripts/sendmail.py Tue Jun 21 14:56:58 2016
@@ -13,17 +13,27 @@ def sendMail(subject, body='', recipient
     msg = MIMEText(body)
     msg['Subject'] = subject
     msg['From'] = sender
-    msg['To'] = recipients
+    if isinstance(recipients, str):
+        msg['To'] = recipients
+    else:
+        msg['To'] = ",".join(recipients)
     if replyTo != None:
         msg['Reply-To'] = replyTo
     smtp = smtplib.SMTP('localhost', port)
-    smtp.sendmail(sender, [recipients], msg.as_string())
+#     smtp.set_debuglevel(True)
+    smtp.sendmail(sender, recipients, msg.as_string())
     smtp.quit()
 
 if __name__ == '__main__':
+    import sys
+    port = 25
+    if len(sys.argv) > 1: # argv[0] is the script name
+        port = int(sys.argv[1])
     # for testing locally:
     # sudo postfix start # MacoxX
     # or start a debug server => need to change the SMTP port
     # python -m smtpd -n -c DebuggingServer localhost:1025
-    sendMail('Test message, please ignore', "Thanks!")
-    print("Sent")
\ No newline at end of file
+    sendMail('Test message, please ignore', "Thanks!", port=port)
+    print("Sent")
+    sendMail('Another Test message, please ignore', "Thanks again!", recipients=['a.b.c','d.e.f'],
port=port)
+    print("Sent second")



Mime
View raw message