Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Prepare actual message
- message = """From: %s\nTo: %s\nSubject: %s\n\n%s
- """ % (FROM, ", ".join(TO), SUBJECT, TEXT)
- try:
- server = smtplib.SMTP("smtp.gmail.com", 587) #start smtp server on port 587
- server.ehlo()
- server.starttls()
- server.login(gmail_user, gmail_pwd) #login to gmail server
- server.sendmail(FROM, TO, message) #actually perform sending of mail
- server.close() #end server
- print 'successfully sent the mail' #alert user mail was sent
- except Exception, e: #else tell user it failed and why (exception e)
- print "failed to send mail, " +str(e)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement