Forums

Internal Server Error (500) raise SMTPAuthenticationError

Error log:ulefr03.eu.pythonanywhere.com.error.log shows : 2021-02-07 17:36:44,187: Internal Server Error: /accounts/password_reset/ Traceback (most recent call last): File "/home/ulefr03/.virtualenvs/env_takenlijst/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner response = get_response(request) File "/home/ulefr03/.virtualenvs/env_takenlijst/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response response = self.process_exception_by_middleware(e, request) File "/home/ulefr03/.virtualenvs/env_takenlijst/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response response = wrapped_callback(request, callback_args, callback_kwargs) File "/home/ulefr03/.virtualenvs/env_takenlijst/lib/python3.7/site-packages/django/views/generic/base.py", line 71, in view return self.dispatch(request, args, kwargs) File "/home/ulefr03/.virtualenvs/env_takenlijst/lib/python3.7/site-packages/django/utils/decorators.py", line 43, in _wrapper return bound_method(*args, kwargs) File "/home/ulefr03/.virtualenvs/env_takenlijst/lib/python3.7/site-packages/django/utils/decorators.py", line 130, in _wrapped_view response = view_func(request, args, kwargs) File "/home/ulefr03/.virtualenvs/env_takenlijst/lib/python3.7/site-packages/django/contrib/auth/views.py", line 222, in dispatch return super().dispatch(args, kwargs) File "/home/ulefr03/.virtualenvs/env_takenlijst/lib/python3.7/site-packages/django/views/generic/base.py", line 97, in dispatch return handler(request, *args, kwargs) File "/home/ulefr03/.virtualenvs/env_takenlijst/lib/python3.7/site-packages/django/views/generic/edit.py", line 142, in post return self.form_valid(form) File "/home/ulefr03/.virtualenvs/env_takenlijst/lib/python3.7/site-packages/django/contrib/auth/views.py", line 235, in form_valid form.save(**opts) File "/home/ulefr03/.virtualenvs/env_takenlijst/lib/python3.7/site-packages/django/contrib/auth/forms.py", line 324, in save user_email, html_email_template_name=html_email_template_name, File "/home/ulefr03/.virtualenvs/env_takenlijst/lib/python3.7/site-packages/django/contrib/auth/forms.py", line 272, in send_mail email_message.send() File "/home/ulefr03/.virtualenvs/env_takenlijst/lib/python3.7/site-packages/django/core/mail/message.py", line 276, in send return self.get_connection(fail_silently).send_messages([self]) File "/home/ulefr03/.virtualenvs/env_takenlijst/lib/python3.7/site-packages/django/core/mail/backends/smtp.py", line 102, in send_messages new_conn_created = self.open() File "/home/ulefr03/.virtualenvs/env_takenlijst/lib/python3.7/site-packages/django/core/mail/backends/smtp.py", line 69, in open self.connection.login(self.username, self.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=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')

my settings are set correctly , also my gmail password ! EMAIL_USE_TLS = True EMAIL_HOST = 'smtp.gmail.com' EMAIL_PORT = 587 EMAIL_HOST_USER = 'ulefr01@gmail.com' EMAIL_HOST_PASSWORD = '.....................' <---- filled in correctly EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

In Dev mode it works but not in prod mode ! Any idea ?

You need to go through the authentication for google on each machine you want to send email from. I'm guessing that you did that on your local machine and not on PythonAnywhere.

It is not working if Google Toegang door minder goed beveiligde apps af staat. Then you get emails like : Google De instelling 'Toegang voor apps met lagere beveiliging' is ingeschakeld ulefr01@gmail.com De instelling 'Toegang voor apps met lagere beveiliging' is ingeschakeld voor je Google-account ulefr01@gmail.com. Als jij dit niet hebt gewijzigd, moet je controleren wat er is gebeurd.

Now i did : Google Toegang door minder goed beveiligde apps staat aan . Bepaalde apps en apparaten gebruiken minder goed beveiligde inlogtechnologie, waardoor je account kwetsbaar wordt. Je kunt de toegang voor dergelijke apps uitschakelen (aanbevolen) of inschakelen als je de apps ondanks de risico's toch wilt gebruiken. Google schakelt de instelling automatisch uit als deze niet wordt gebruikt. Meer informatie Apps met lagere beveiliging toestaan: AAN It works in dev mode on my local machine.and i receive an email with a link to change my password U ontvangt deze e-mail, omdat u een aanvraag voor opnieuw instellen van het wachtwoord voor uw account op 127.0.0.1:8000 hebt gedaan.

Ga naar de volgende pagina en kies een nieuw wachtwoord:

http://127.0.0.1:8000/accounts/reset/Mg/ahpv5s-4c0b6905c5319f6be3d477bd4abcbd6c/

Uw gebruikersnaam, mocht u deze vergeten zijn: test_ulefr01

Bedankt voor het gebruik van onze website!

Het 127.0.0.1-team

In Prod mode on pythonanywhere my site in sqlite3 is set to 'ulefr03.eu.pythonanywhere.com' but when i try to change my password i try to send an email but i get above the Server Error (500) and no email is sent with my google account !

my google account is accepting now : Toegang door minder goed beveiligde apps Bepaalde apps en apparaten gebruiken minder goed beveiligde inlogtechnologie, waardoor je account kwetsbaar wordt. Je kunt de toegang voor dergelijke apps uitschakelen (aanbevolen) of inschakelen als je de apps ondanks de risico's toch wilt gebruiken. Google schakelt de instelling automatisch uit als deze niet wordt gebruikt. Meer informatie Apps met lagere beveiliging toestaan: AAN In dev mode my site can send emails to 127.0.0.1:8000 and i get the request to change my password. but in prod mode my site i can NOT send emails to ulefr03.eu.pythonanywhere.com because of above server error !!

This was done : "Go to this link and select Turn On

https://www.google.com/settings/security/lesssecureapps"

This was the truck to allow sending emails and it works in dev mode

On Prod mode on pythonanywhere this is not working and i get above Internal Server error

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

Look in your error log and you will see an exception with a URL that you need to visit to authorize the app. You need to follow that instructions in the error message.

Error log shows : 2021-02-08 11:01:37,548: Internal Server Error: /accounts/password_reset/ Traceback (most recent call last): File "/home/ulefr03/.virtualenvs/env_takenlijst/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner response = get_response(request) File "/home/ulefr03/.virtualenvs/env_takenlijst/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response response = self.process_exception_by_middleware(e, request) File "/home/ulefr03/.virtualenvs/env_takenlijst/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response response = wrapped_callback(request, callback_args, callback_kwargs) File "/home/ulefr03/.virtualenvs/env_takenlijst/lib/python3.7/site-packages/django/views/generic/base.py", line 71, in view return self.dispatch(request, args, kwargs) File "/home/ulefr03/.virtualenvs/env_takenlijst/lib/python3.7/site-packages/django/utils/decorators.py", line 43, in _wrapper return bound_method(*args, kwargs) File "/home/ulefr03/.virtualenvs/env_takenlijst/lib/python3.7/site-packages/django/utils/decorators.py", line 130, in _wrapped_view response = view_func(request, args, kwargs) File "/home/ulefr03/.virtualenvs/env_takenlijst/lib/python3.7/site-packages/django/contrib/auth/views.py", line 222, in dispatch return super().dispatch(args, kwargs) File "/home/ulefr03/.virtualenvs/env_takenlijst/lib/python3.7/site-packages/django/views/generic/base.py", line 97, in dispatch return handler(request, *args, kwargs) File "/home/ulefr03/.virtualenvs/env_takenlijst/lib/python3.7/site-packages/django/views/generic/edit.py", line 142, in post return self.form_valid(form) File "/home/ulefr03/.virtualenvs/env_takenlijst/lib/python3.7/site-packages/django/contrib/auth/views.py", line 235, in form_valid form.save(**opts) File "/home/ulefr03/.virtualenvs/env_takenlijst/lib/python3.7/site-packages/django/contrib/auth/forms.py", line 324, in save user_email, html_email_template_name=html_email_template_name, File "/home/ulefr03/.virtualenvs/env_takenlijst/lib/python3.7/site-packages/django/contrib/auth/forms.py", line 272, in send_mail email_message.send() File "/home/ulefr03/.virtualenvs/env_takenlijst/lib/python3.7/site-packages/django/core/mail/message.py", line 277, in send return self.get_connection(fail_silently).send_messages([self]) File "/home/ulefr03/.virtualenvs/env_takenlijst/lib/python3.7/site-packages/django/core/mail/backends/smtp.py", line 104, in send_messages new_conn_created = self.open() File "/home/ulefr03/.virtualenvs/env_takenlijst/lib/python3.7/site-packages/django/core/mail/backends/smtp.py", line 71, in open self.connection.login(self.username, self.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=AKgnsbu\n5.7.14 chHOtcGAEAYb4BNHNoe0EubjT-_sc_NbpsobbLkv4nOxssypkWJa7hKmpkHfJvd7XlXiC\n5.7.14 J8Zx0w0P2HhoqdvwoHKa00D1a9ON86UOQ7JZXSHOYDwjPG2UZwx58HU4bwjZNmE_\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 s4sm26601280wrt.85 - gsmtp')

The email and password was correctly filled in ! In dev mode it works perfect with the same email address and password In prod mode I use same email address and password but I get this internal server error

Did you follow the instructions in that error message?

yes i did... what is the SMTPAuthenticationError and how can i solve the SMTPAuthenticationError ? Why i have this error on the ulefr03.eu.pythonanywhere.com when i try the https://ulefr03.eu.pythonanywhere.com/accounts/password_reset/ ? it works on my 127.0.0.1:8000 but not on https://ulefr03.eu.pythonanywhere.com ?

enter link description here

enter link description here

see https://ibb.co/gj6rTLy

Try using an app-specific password -- the details are at the bottom of this help page. It's a different thing to the "less secure apps" setting ("minder goed beveiligde apps") that you are currently using.

Same problem when I am using SendGrid !

ah did you try using app specific passwords?