Created
July 31, 2018 23:08
-
-
Save leo-isso/6ef3a5eb893b47d00abd0db0ae5b26db to your computer and use it in GitHub Desktop.
Python Simple Gmail SMTP
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 | |
gmail_smtp = 'smtp.gmail.com:587' | |
from_mail = '[email protected]' | |
to_mail = '[email protected]' | |
mail_subject = 'Title/Subject' | |
mail_body = 'My email content...' | |
mail_content = "\r\n".join([ | |
"From: " + from_mail, | |
"To: " + to_mail, | |
"Subject: " + mail_subject, | |
"", | |
mail_body | |
]) | |
username = from_mail | |
password = 'password' | |
server = smtplib.SMTP(gmail_smtp) | |
server.ehlo() | |
server.starttls() | |
server.login(username, password) | |
server.sendmail(from_mail, to_mail, mail_body) | |
server.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment