Created
January 8, 2020 21:19
-
-
Save dbrant/67c79ae82b4bcac781caf6700853a00c to your computer and use it in GitHub Desktop.
Send email via python
This file contains 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 | |
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