Error sending email: raise SMTPAuthenticationError(code, resp)
Solution 1
Go to Google's Account Security Settings: www.google.com/settings/security
Find the field "Access for less secure apps". Set it to "Allowed".
Try your script again, changing server.sendemail()
to server.sendmail()
Solution 2
(534, b'5.7.14 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/answer/78754 h16sm7090987wrc.89 - gsmtp')
try https://myaccount.google.com/security#connectedapps
Allow less secure apps: ON Some apps and devices use less secure sign-in technology, which could leave your account vulnerable. You can turn off access for these apps (which we recommend) or choose to use them despite the risks.
UserX
Updated on February 07, 2022Comments
-
UserX over 2 years
Im trying to send emails with smtp module, but Im having an error:
File "/usr/lib/python2.7/smtplib.py", in login raise SMTPAuthenticationError(code, resp) smtplib.SMTPAuthenticationError: (534, '5.7.14)...
Someone already had this error? Do you know how to fix?
The code:
def sendNotification(): recepients_list = "[email protected]" subject = 'Subject' message = "Message" sendemail(recepients_list,subject,message) def sendemail(to_addr_list, subject, message): username = '[email protected]' password = 'passtest' from_addr = '[email protected]' server = smtplib.SMTP('smtp.gmail.com', 587) server.ehlo() server.starttls() server.login(username,password) newmessage = '\r\n'.join([ 'To: %s' %recepient_list, 'From: %s' % from_addr, 'Subject: %s' %subject, '', message ]) try: server.sendemail(from_addr, to_addr_list,newmessage) print 'notification sent' except: print 'error sending notification' server.quit() sendNotification()
-
proprius over 8 yearsEven after enabling for less secured devices, i am not able to login. My password is correct and I am using the same code as mentioned in websites to be correct
-
Anupam over 6 years@proprius same for me. did you figure it out?
-
Aashish Kumar about 6 yearsuse this link that directly landed you on the desired page: https://www.google.com/settings/security/lesssecureapps
-
Nityesh Agarwal over 5 years@Anupam same for me. Did you figure it out?
-
Anupam over 5 years@NityeshAgarwal If I remember correctly, I found it was automatically setting it to disabled even when I enabled it. I think I just tried a couple of times and it worked
-
Nityesh Agarwal over 5 yearsActually I found that I was making an extremely stupid mistake by entering my email address as
[email protected]
and not[email protected]
. Thanks anyway @Anupam :)