Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send emails from Gmail without turning on "allow less secure apps" setting?

Is there any way to send an email in a Django project without turning on the "allow less secure apps" feature? Is using OAuth2 a must or can I send it using Google's API?

So far, I just use:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = '587'
EMAIL_HOST_USER = 'myemailaddress'
EMAIL_HOST_PASSWORD = 'password'
EMAIL_USE_TLS = True
EMAIL_USE_SSL = False

But this gives me an SMTPAuthenticationError, which only works when I turn on "allow less secure apps" in Google. Is there any way to circumvent this without using OAuth2 and allow multiple users to login to that account easily?

like image 755
WannaInternet Avatar asked Sep 06 '25 03:09

WannaInternet


1 Answers

Using the gmail app password through you can send the email not provide the actual password and no one can login in your account. Without enable less secure apps setting here is give the link try and it's work let me know if it right google or gmail app password

after it change the actual password to your app password in

setting.py file EMAIL_HOST_PASSWORD = 'your app password' give by google not change in other constant

if you do not use 2 step email verification you need to use third party service here i give the link you see sendgrid

like image 183
l.b.vasoya Avatar answered Sep 08 '25 22:09

l.b.vasoya