Skip to content

Instantly share code, notes, and snippets.

@leo-isso
Created July 31, 2018 23:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leo-isso/6ef3a5eb893b47d00abd0db0ae5b26db to your computer and use it in GitHub Desktop.
Save leo-isso/6ef3a5eb893b47d00abd0db0ae5b26db to your computer and use it in GitHub Desktop.
Python Simple Gmail SMTP
import smtplib
gmail_smtp = 'smtp.gmail.com:587'
from_mail = 'from_mail@gmail.com'
to_mail = 'to_mail@gmail.com'
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