Skip to content

Instantly share code, notes, and snippets.

@dbrant
Created January 8, 2020 21:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbrant/67c79ae82b4bcac781caf6700853a00c to your computer and use it in GitHub Desktop.
Save dbrant/67c79ae82b4bcac781caf6700853a00c to your computer and use it in GitHub Desktop.
Send email via python
import smtplib
server = smtplib.SMTP("smtp.gmail.com", 587)
server.ehlo()
server.starttls()
server.ehlo()
server.login("account@example.com", password)
msg = "To: destination@example.com\n"
msg += "From: source@example.com\n"
msg += "Subject: "
msg += subject
msg += "\n\n"
msg += message
server.sendmail("source@example.com", "destination@example.com", msg)
server.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment