Created
February 9, 2017 10:00
-
-
Save achilleas-k/b67dd25e249f1246f6b1d401d9c4fe4c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import smtplib | |
session = smtplib.SMTP('smtp.gmail.com', 587) | |
session.starttls() | |
session.login("username", "password") | |
subject = "Subject" | |
headers = ("From: {fromaddress}\n" | |
"To: {toaddress}\n" | |
"Subject: {subject}\n" | |
"mime-version: 1.0\n" | |
"content-type: text").format(fromaddress="from", | |
subject=subject, | |
toaddress="to") | |
body = "body" | |
content = headers + "\n\n" + body | |
session.sendmail("from", "to", content) | |
session.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment