You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@community.apache.org by se...@apache.org on 2016/04/12 20:16:02 UTC

svn commit: r1738841 - /comdev/reporter.apache.org/trunk/scripts/sendmail.py

Author: sebb
Date: Tue Apr 12 18:16:02 2016
New Revision: 1738841

URL: http://svn.apache.org/viewvc?rev=1738841&view=rev
Log:
Simple SMTP interface

Added:
    comdev/reporter.apache.org/trunk/scripts/sendmail.py   (with props)

Added: comdev/reporter.apache.org/trunk/scripts/sendmail.py
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/scripts/sendmail.py?rev=1738841&view=auto
==============================================================================
--- comdev/reporter.apache.org/trunk/scripts/sendmail.py (added)
+++ comdev/reporter.apache.org/trunk/scripts/sendmail.py Tue Apr 12 18:16:02 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@reporter.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/reporter.apache.org/trunk/scripts/sendmail.py
------------------------------------------------------------------------------
    svn:eol-style = native