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 atn5.7.8 https://support.google.com/mail/?p=BadCredentials a24sm3958276ljd.32 – gsmtp’) Exception Location: C:UsersAdministratorAppDataLocalProgramsPythonPython37libsmtplib.py in auth, line 642 Python Executable: C:UsersAdministratorAppDataLocalProgramsPythonPython37python.exe Python Version: 3.7.2 Python Path:
[‘C:UsersAdministratorDesktopdjango_project’, ‘C:UsersAdministratorAppDataLocalProgramsPythonPython37python37.zip’, ‘C:UsersAdministratorAppDataLocalProgramsPythonPython37DLLs’, ‘C:UsersAdministratorAppDataLocalProgramsPythonPython37lib’, ‘C:UsersAdministratorAppDataLocalProgramsPythonPython37’, ‘C:UsersAdministratorAppDataRoamingPythonPython37site-packages’, ‘C:UsersAdministratorAppDataLocalProgramsPythonPython37libsite-packages’] Server time: Thu, 4 Apr 2019 12:24:22 +0000Learn more atn5.7.8Request Method: POST RequestDjango Version: 2.1.7Exception Value: (535,
Advertisement
Answer
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