Created
May 21, 2020 16:35
-
-
Save dreamspy/b87024d86c98d985f218f4e758a49c62 to your computer and use it in GitHub Desktop.
Test SMPT python script
This file contains hidden or 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 sys | |
gmail_user = '[email protected]' | |
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