Django SMTPAuthenticationError
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.
Django - SMTPAuthenticationError
You need to add SMTP server settings to your settings.py
file. Example:
EMAIL_HOST = 'smtp.example.com'
EMAIL_PORT = 25
EMAIL_HOST_USER = 'mailer@example.com'
EMAIL_HOST_PASSWORD = 'password'
EMAIL_USE_TLS = True
From Django documentation:
Mail is sent using the SMTP host and port specified in the EMAIL_HOST and EMAIL_PORT settings. The EMAIL_HOST_USER and EMAIL_HOST_PASSWORD settings, if set, are used to authenticate to the SMTP server, and the EMAIL_USE_TLS setting controls whether a secure connection is used.
SMTPAuthenticationError at /password-reset/
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
Gmail SMTPAuthenticationError when I attempt to send email via django
If you have activated two-step verification, you need to turn that off. Also ,you can try another thing. Go to https://www.google.com/settings/security/lesssecureapps and https://myaccount.google.com/security?pli=1#connectedapps, allow access for the less secure app. Google might consider your server's sign-in process as less secure sign-in technology, which makes your account more vulnerable. So allowing access might help you.
Django Email sending SMTP Error, cant send a mail
Google disabled/discontinued the Less Secure App feature as of May 30th, 2022.
As recommended by @MeL, you could use an alternative but you can still use Gmail to send emails using Django
. You can read this blog Mail setup on django using Gmail to help with guiding the setup if you're unfamiliar with setting up Google App Passwords.
In addition to that, you'll need to do one last thing to activate the app password to be used by Django
. You should visit the site https://accounts.google.com/DisplayUnlockCaptcha, select continue and you're all set.
Related Topics
How to Catch a Numpy Warning Like It's an Exception (Not Just for Testing)
How to Run Scrapy from Within a Python Script
Python Global Exception Handling
Easy Way of Finding Decimal Places
How to Trigger Function on Value Change
How to Split an Iterable in Constant-Size Chunks
Python Selenium Chrome Webdriver
Use Python's String.Replace VS Re.Sub
Extrapolate Values in Pandas Dataframe
How to Count the Nan Values in a Column in Pandas Dataframe
Accessing Object Memory Address
How to Get the "Id" After Insert into MySQL Database with Python
Why Does Defining _Getitem_ on a Class Make It Iterable in Python
Asyncio.Sleep() VS Time.Sleep()
Calculating Arithmetic Mean (One Type of Average) in Python