1

I am very new to python. I was trying to send a mail using a python script. But getting the below mentioned error:

$ python main.py
Traceback (most recent call last):
  File "main.py", line 8, in <module>
    server.login("[email protected]", "*********")
  File "C:\Python27\lib\smtplib.py", line 622, in login
    raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (534, '5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbvm\n5.7.14 7HCHLzWCRCqEWA7MrN_ugeXO84BVMOFJ0g1E6_G7PGiHJmzxMOLKwsWe8s1STDSdnu62FE\n5.7.14 kiIxlsG8SNxbLi6J9ldrBZZlGEq7iQwdu_jyiZqCBnbaMilPIb8h0n8qbQ-qIlgqkBwb8n\n5.7.14 Fu3wlNDH2Eb8nSYcTEZgZT7o-LS_tdj393kLlex2GILGCcy7McM6r72Ml1u7Dl-fc7hWjM\n5.7.14 int0yILB5Ab1MYcNt8uigK2ZyemJU> 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 fj19sm61312778pab.37 - gsmtp')

But I mentioned the correct pw and email in the script. main.py:

import smtplib
msg = "YOUR MESSAGE!"
server = smtplib.SMTP('smtp.googlemail.com')
server.ehlo()
server.starttls()
server.login("[email protected]", "mypassword")    
server.sendmail("[email protected]", "[email protected]",msg)
server.quit()
1

2 Answers 2

0

Are you sure the configuration is correct? I think Gmail SMTP is smtp.gmail.com. And try to add the port:

server = smtplib.SMTP('smtp.gmail.com', 587)

If it still doesn't work, Google is probably blocking your app. For more information see this link

Sign up to request clarification or add additional context in comments.

Comments

0

I could solve it following below steps:

Go to Google's Account Security Settings: www.google.com/settings/security

Find the field "Access for less secure apps". Set it to "Allowed".

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.