Skip to content

Instantly share code, notes, and snippets.

@krosti
Created May 15, 2012 21:25
Show Gist options
  • Save krosti/2705271 to your computer and use it in GitHub Desktop.
Save krosti/2705271 to your computer and use it in GitHub Desktop.
Minimalistic Email w/ Gmail Sender
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