Created
August 26, 2012 17:16
-
-
Save mitchtech/3481745 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
import smtplib | |
from email.mime.text import MIMEText | |
USERNAME = "[email protected]" | |
PASSWORD = "password" | |
MAILTO = "[email protected]" | |
msg = MIMEText('This is the body of the email') | |
msg['Subject'] = 'The email subject' | |
msg['From'] = USERNAME | |
msg['To'] = MAILTO | |
server = smtplib.SMTP('smtp.gmail.com:587') | |
server.ehlo_or_helo_if_needed() | |
server.starttls() | |
server.ehlo_or_helo_if_needed() | |
server.login(USERNAME,PASSWORD) | |
server.sendmail(USERNAME, MAILTO, msg.as_string()) | |
server.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@marcos10soares: The code does no longer work since Google improved its security standards. You have to create an app password.