Last active
July 24, 2018 11:56
-
-
Save jcarlosroldan/e596c0f896f5f7d78456a98b3ecbaab9 to your computer and use it in GitHub Desktop.
Send a mail using SMTP
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
from smtplib import SMTP | |
def send_gmail(to, subject, text, username="********@gmail.com", password="********"): | |
""" Send a mail using simple SMTP. """ | |
server = SMTP('smtp.gmail.com:587') | |
server.starttls() | |
server.login(username, password) | |
msg = "From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n%s"%(username, to, subject, text) | |
server.sendmail(username, to, msg) | |
server.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment