Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Test SMPT python script
import smtplib
import sys
gmail_user = 'emailaddress@pan.is'
gmail_password = 'password'
sent_from = gmail_user
to = [gmail_user, gmail_user]
subject = 'OMG Super Important Message'
body = 'the body'
email_text = """\
From: %s
To: %s
Subject: %s
%s
""" % (sent_from, ", ".join(to), subject, body)
try:
server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
server.ehlo()
server.login(gmail_user, gmail_password)
server.sendmail(sent_from, to, email_text)
server.close()
print 'Email sent!'
except:
print 'Something went wrong...'
print "Unexpected error:", sys.exc_info()[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.