Skip to content

Instantly share code, notes, and snippets.

@rsmoz
Created August 22, 2012 05:35
Show Gist options
  • Save rsmoz/3422524 to your computer and use it in GitHub Desktop.
Save rsmoz/3422524 to your computer and use it in GitHub Desktop.
Using Python smtp with Gmail to send email
def sendIt(to, gmail_address, gmail_pwd, body,
from smtplib import SMTP as smtplibsmtp
smtpserver = smtplibsmtp("smtp.gmail.com",587)
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.ehlo
smtpserver.login(gmail_user, gmail_pwd)
header = 'To:' + to + '\n' + 'From: ' + gmail_user + '\n' + 'Subject:testing \n'
msg = header + '\n ' + body + ' \n\n'
smtpserver.sendmail(gmail_user, to, msg)
smtpserver.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment