Last active
August 29, 2015 14:02
-
-
Save alaudet/afc10137539b68d39228 to your computer and use it in GitHub Desktop.
smtplib gmail
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 | |
import string | |
def smtp_gmail(): | |
username = "your smtp username here " | |
password = "your smtp password here" | |
smtp_server = "smtp.gmail.com:587" | |
email_from = "sender email" | |
email_to = "recipient email or wireless carrier sms #" | |
email_body = string.join(( | |
"From: %s" % email_from, | |
"To: %s" % email_to, | |
"Subject: This is my subject line!", | |
"", | |
"This is my message that can also have a %s" % (mystring | |
),), "\r\n" | |
) | |
server = smtplib.SMTP(smtp_server) | |
server.starttls() | |
server.login(username, password) | |
server.sendmail(email_from, email_to, email_body) | |
server.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment