Search code examples
pythondjangoauthenticationgmailsmtp-auth

Django SMTPAuthenticationError


I am new in django and developing a web application using django. I have successfully set the Signup functionality using Userena in my web application and can Register as a user with Verification Email. I can show you my SMTP settings in my settings.py file

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = '[email protected]'
DEFAULT_FROM_EMAIL = '[email protected]'
SERVER_EMAIL = '[email protected]'
EMAIL_HOST_PASSWORD = '**************'

everything was fine before i have changed my EMAIL_HOST_PASSWORD

Infact, for some reason I have to change the previous password of that SERVER_EMAIL([email protected]). I have already edit the EMAIL_HOST_PASSWORD according to the new SERVER_EMAIL password.

but now, if I want to register as a new user, I am facing the following error

SMTPAuthenticationError at /accounts/signup/
(534, '5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbvNq\n5.7.14 S3l1pFXENupDa_SdPphNHrnzeLPUOyf6O0l1s31w7h_UARx11P89AxPeeZ6xBi2KeQRjsw\n5.7.14 nvpxZhPVv771W9ljEDyeWnqpqv3_nakuPo36BEl3IlYj9qVujNB5cm0TYFf9LQAxRjFdda\n5.7.14 xh-y5spA9zIQONDsvRRgN3e0DXoIkgxTO3Mu75IaACi-XlvFtFfPBiQ81gUrBZ_PhZsBmh\n5.7.14 ajsSf-flNEmoSydyOTNdmwdB0__8> 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/bin/answer.py?answer=78754 40sm12125121qgi.47 - gsmtp')

Solution

  • A relatively recent change in Google's authentication system means you're going to have to "allow less secure app access" to your Google account, in order for this to work.

    In your error, you are recommended to visit this link: https://support.google.com/mail/answer/78754

    On that page:

    Step #2 asks you to try Displaying an Unlock Captcha

    Step #3 explains how to allow less secure app access. In summary:

    Go to Allow less secure apps and choose "Allow" to let less secure apps access your Google account. We don't recommend this option because it may make it easier for someone to gain access to your account.