Last active
August 3, 2016 22:37
-
-
Save olafurjohannsson/3826230ae838d8653f69 to your computer and use it in GitHub Desktop.
Send email with 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
def send_email(to, _from, subject, message): | |
msg = "\r\n".join([ | |
"From: " + _from, | |
"To: " + to, | |
"Subject: " + subject, | |
"", | |
message | |
]) | |
server = smtplib.SMTP(SMTP_SERVER) | |
server.ehlo() | |
server.starttls() | |
# The account you login into to send the email | |
server.login(EMAIL_USERNAME, EMAIL_PASSWORD) | |
server.sendmail(_from, to, msg) | |
server.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment