community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1740220 - /comdev/projects.apache.org/scripts/cronjobs/sendmail.py
Date Thu, 21 Apr 2016 00:42:16 GMT
Author: sebb
Date: Thu Apr 21 00:42:16 2016
New Revision: 1740220

URL: http://svn.apache.org/viewvc?rev=1740220&view=rev
Log:
Allow sending mail

Added:
    comdev/projects.apache.org/scripts/cronjobs/sendmail.py   (with props)

Added: comdev/projects.apache.org/scripts/cronjobs/sendmail.py
URL: http://svn.apache.org/viewvc/comdev/projects.apache.org/scripts/cronjobs/sendmail.py?rev=1740220&view=auto
==============================================================================
--- comdev/projects.apache.org/scripts/cronjobs/sendmail.py (added)
+++ comdev/projects.apache.org/scripts/cronjobs/sendmail.py Thu Apr 21 00:42:16 2016
@@ -0,0 +1,23 @@
+# Simple SMTP interface
+import smtplib
+
+# Import the email modules we'll need
+from email.mime.text import MIMEText
+
+def sendMail(subject, body, recipients, sender='no-reply@projects.apache.org', port=25):
+    # Create a text/plain message
+    msg = MIMEText(body)
+    msg['Subject'] = subject
+    msg['From'] = sender
+    msg['To'] = recipients
+    smtp = smtplib.SMTP('localhost', port)
+    smtp.sendmail(sender, [recipients], msg.as_string())
+    smtp.quit()
+
+if __name__ == '__main__':
+    # for testing locally:
+    # sudo postfix start # MacoxX
+    # or start a debug server => need to change the SMTP port above
+    # python -m smtpd -n -c DebuggingServer localhost:1025
+    sendMail('Example SMTP message', "The quick brown fox ...", 'no-one')
+    print("Sent")
\ No newline at end of file

Propchange: comdev/projects.apache.org/scripts/cronjobs/sendmail.py
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message