Skip to content

Instantly share code, notes, and snippets.

@oba11
Created November 17, 2016 00:16
Show Gist options
  • Save oba11/3446f6f519b7e09c9d4e45728f73799e to your computer and use it in GitHub Desktop.
Save oba11/3446f6f519b7e09c9d4e45728f73799e to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import smtplib
sender = 'printer-no-reply@gmail.com'
receiver = ''
smtp_address = '127.0.0.1'
message = """From: From Person <%s>
To: To Person <%s>
Subject: SMTP e-mail test
This is a test e-mail message.
""" % (sender, receiver)
try:
smtpObj = smtplib.SMTP(smtp_address)
smtpObj.sendmail(sender, receiver, message)
print "Successfully sent email"
except smtplib.SMTPException:
print "Error: unable to send email"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment