Created
April 3, 2015 13:38
Revisions
-
bot11 created this gist
Apr 3, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ import smtplib gmail_user = "[email protected]" gmail_pwd = "frompwd" TO = '[email protected]' SUBJECT = "Testing sending using gmail" TEXT = "Testing sending mail using gmail servers" server = smtplib.SMTP('smtp.gmail.com', 587) server.ehlo() server.starttls() server.login(gmail_user, gmail_pwd) BODY = '\r\n'.join(['To: %s' % TO, 'From: %s' % gmail_user, 'Subject: %s' % SUBJECT, '', TEXT]) server.sendmail(gmail_user, [TO], BODY) print ('email sent') #If got the following error: ''' Traceback (most recent call last): File "send_from_gmail.py", line 13, in <module> server.login(gmail_user, gmail_pwd) File "/usr/lib/python2.7/smtplib.py", line 615, in login raise SMTPAuthenticationError(code, resp) smtplib.SMTPAuthenticationError: (534, '5.7.14 <https://accounts.google.com/...........................................................................> Please log in via your web browser and\n5.7.14 then try again.\n5.7.14 Learn more at\n5.7.14 https://support.google.com/mail/bin/answer.py?answer=XXXX XXXXXXX.2 - gsmtp') Access : https://www.google.com/settings/security/lesssecureapps and set Access for less secure apps : turn off '''