Skip to content

Instantly share code, notes, and snippets.

@dbrant dbrant/sendemail.py

Created Jan 8, 2020
Embed
What would you like to do?
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
You can’t perform that action at this time.