Created
May 15, 2012 21:25
-
-
Save krosti/2705271 to your computer and use it in GitHub Desktop.
Minimalistic Email w/ Gmail Sender
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 urllib | |
from email.mime.multipart import MIMEMultipart | |
from email.mime.text import MIMEText | |
# Usr data | |
fromaddr = '[email protected]' | |
toaddrs = '[email protected]' | |
# Parse file to HTML | |
f = urllib.urlopen("index.html") | |
msg = f.read() | |
msg = MIMEText(msg, 'html') | |
# Credentials (if needed) | |
username = '[email protected]' | |
password = 'your-pw' | |
# The actual mail send | |
server = smtplib.SMTP('smtp.gmail.com:587') | |
server.starttls() | |
server.login(username,password) | |
server.sendmail(fromaddr, toaddrs, msg.as_string()) | |
server.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment