Last active
August 29, 2015 14:04
-
-
Save gene1wood/d82cd0ff296f5846eb48 to your computer and use it in GitHub Desktop.
Simple example of how to send email in Python through authenticated SMTP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fromaddr = 'me@example.com' | |
toaddr = 'you@example.org' | |
servername = 'smtp.example.com' | |
username = 'username' | |
password = 'password' | |
import smtplib | |
import time | |
server = smtplib.SMTP(servername, 25) | |
server.set_debuglevel(1) | |
server.login(username, password) | |
msg='''From: %(from)s\nTo: %(to)s\nSubject: This is a test sent at %(date)s\nThis is a test sent at %(date)s | |
''' % {'from' : fromaddr, 'to': toaddr, 'date': time.strftime('%x %X')} | |
server.sendmail(fromaddr, toaddr, msg) | |
server.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment