Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SMTPAuthenticationError at /password-reset/

I am new in Django. I am trying to add a feature in my project that enables user to reset his password through given email. These configurations are in development and not production. This is my configuration in settings.py

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = os.environ.get('EMAIL_USER')
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_PASS')

I tried these but nothing seems to be working. I enabled IMAP from gmail settings as well. Can you please help me what am I doing wrong in here! In case if you want to see full error.

SMTPAuthenticationError at /password-reset/ (535, b'5.7.8 Username and Password not accepted.

https://support.google.com/mail/?p=BadCredentials a24sm3958276ljd.32 - gsmtp')

URL: http://localhost:8000/password-reset/ Exception Type: SMTPAuthenticationError b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/?p=BadCredentials a24sm3958276ljd.32 - gsmtp') Exception Location: C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\smtplib.py in auth, line 642 Python Executable: C:\Users\Administrator\AppData\Local\Programs\Python\Python37\python.exe Python Version: 3.7.2 Python Path:
['C:\Users\Administrator\Desktop\django_project', 'C:\Users\Administrator\AppData\Local\Programs\Python\Python37\python37.zip', 'C:\Users\Administrator\AppData\Local\Programs\Python\Python37\DLLs', 'C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib', 'C:\Users\Administrator\AppData\Local\Programs\Python\Python37', 'C:\Users\Administrator\AppData\Roaming\Python\Python37\site-packages', 'C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages'] Server time: Thu, 4 Apr 2019 12:24:22 +0000Learn more at\n5.7.8Request Method: POST RequestDjango Version: 2.1.7Exception Value: (535,

like image 995
Mir Stephen Avatar asked Dec 12 '25 01:12

Mir Stephen


1 Answers

Would you mind double checking if your environment variables are set correctly? Also, did you enable this feature on your Google account: https://www.google.com/settings/security/lesssecureapps?

Take a look at this answer, as it might help you as well: SMTPAuthenticationError when sending mail using gmail and python

like image 97
Marcelo Cardoso Avatar answered Dec 14 '25 13:12

Marcelo Cardoso



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!