Forums

smtplib.SMTPAuthenticationError Issue

Hi , While sending mail from Gmail Account I am facing this issue,although less secure app access is on.

Traceback (most recent call last):
  File "sending_mail_snippet.py", line 27, in <module>
    s.login(fromaddr,"criccdar@1234")
  File "/usr/lib/python3.6/smtplib.py", line 730, in login
    raise last_exception
  File "/usr/lib/python3.6/smtplib.py", line 721, in login
    initial_response_ok=initial_response_ok)
  File "/usr/lib/python3.6/smtplib.py", line 642, in auth
    raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (534, b'5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbs\n5.7.14 L2007kDCe4ke
ChXS7TDZA_ZT0abh3oBPrJbMicRldQI83K0E3ORDkcqEN23x8turoFV3f\n5.7.14 wJOhcs24MXlJy_-kYgPZ_JA1S6FXEqua4mr8w2FSqJdRY8lhKBGmbKN1NJzHxfSL>\n5.7.1
4 Please log in via your web browser and then try again.\n5.7.14  Learn more at\n5.7.14  https://support.google.com/mail/answer/78754 l95s
m1002890qte.36 - gsmtp')

[edit by admin: formatting]

Check out the "Use Gmail's SMTP servers" section of this help page -- in particular the part on app-specific passwords.

I get this same problem ! In dev mode with DEBUG = True it is working ok. In Prod mode with DEBUG = False it is not working because of the Server Error (500)

File "/usr/lib/python3.7/smtplib.py", line 642, in auth
  raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (534, b'5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbv\n5.7.14 YvzmuwTqKFmdOtyqVnSEbWeYUN3hob1swJd9YISfeuo9SFWtPcFqA2YBwwQmd4Wx10w2d\n5.7.14 rvp5oU95Tu50Vubs9TYGpXG86ZWKha7IDxT3UDAsM8y7zupbAJPuBQ3_lrDrdyKA>\n5.7.14 Please log in via your web browser and then try again.\n5.7.14  Learn more at\n5.7.14  https://support.google.com/mail/answer/78754 f4sm23479179wrs.34 - gsmtp')

The email and password are correct and I have enabled access to less secure apps on my account.

Did you follow the instructions in the error message and go to that URL to authorise it?

[formatted by admin]

File "/home/pondicherryfashionmodels/.virtualenvs/flaskk/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "./main.py", line 50, in register
    mail.send(msg)
  File "/home/pondicherryfashionmodels/.virtualenvs/flaskk/lib/python3.7/site-packages/flask_mail.py", line 491, in send
    with self.connect() as connection:
  File "/home/pondicherryfashionmodels/.virtualenvs/flaskk/lib/python3.7/site-packages/flask_mail.py", line 144, in __enter__
    self.host = self.configure_host()
  File "/home/pondicherryfashionmodels/.virtualenvs/flaskk/lib/python3.7/site-packages/flask_mail.py", line 165, in configure_host
    host.login(self.mail.username, self.mail.password)
  File "/usr/lib/python3.7/smtplib.py", line 730, in login
    raise last_exception
  File "/usr/lib/python3.7/smtplib.py", line 721, in login
    initial_response_ok=initial_response_ok)
  File "/usr/lib/python3.7/smtplib.py", line 642, in auth
    raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (534, b'5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbt\n5.7.14 8foqurWtmBPcVQFSeV5JTTQ236AB1ZtDGpbKeidjlgYBK06N7q7Py3lAc3Ac1rgKYHihZ\n5.7.14 VYSY3XqE0bB9-mxEr9udEqZbPUpkzjmz9YA5amurKhvBHGs0oGKWFQO85Ty5acsN>\n5.7.14 Please log in via your web browser and then try again.\n5.7.14  Learn more at\n5.7.14  https://support.google.com/mail/answer/78754 q7sm2534262qki.17 - gsmtp')

i'm facing the same error, but my project is in flask i'm enabled to less secure apps on my account

Did you follow the link in the error?

i don't know what to do?

I see that we're corresponding about this over email too, so we'll answer there to avoid duplication.

i turn ON 2step verification and i got an 16 digit app password and then what should it do?

According to our conversation in emails, the issue seems to be solved.

what was the solving error??

Take a look at Gmail App-Specific Passwords | PythonAnywhere help