SMTP Authentification error

1,782 views
Skip to first unread message

Delvin Alexander

unread,
Apr 27, 2022, 1:37:53 AM4/27/22
to Django users
Hello everyone, 

May you please assist in informing me on what i need to do to resolve this issue. 

- SMTPAuthenticationError at /password-reset/
- (535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/?p=BadCredentials j64-20020a62c543000000b0050d260c0ea8sm13366402pfg.110 - gsmtp')


I included the 16 character code to my environment variable and called it in my settings.pymfile,  but still the error occurs. Also here is my settings.py file:

- 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('DB_USER')
EMAIL_HOST_PASSWORD = os.environ.get('DB_PASSWORD')

Julio Cojom

unread,
Apr 27, 2022, 2:33:20 AM4/27/22
to django...@googlegroups.com
Seem pretty clear, you are calling db user and db password instead of email and email password,

EMAIL_HOST_USER = os.environ.get('DB_USER')
EMAIL_HOST_PASSWORD = os.environ.get('DB_PASSWORD')

Regards,

Julio Cojom

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c18935a8-43bf-4a15-a5ba-95209009498dn%40googlegroups.com.

Lakshyaraj Dash X-D 25

unread,
Apr 27, 2022, 3:27:02 AM4/27/22
to django...@googlegroups.com
Check whether you have turned on less secure apps or not.

--

Delvin Alexander

unread,
Apr 27, 2022, 11:00:02 PM4/27/22
to Django users
i thought that because i had that as my variable name that i had to call upon that name. Thank you, i will give that a try. 

Delvin Alexander

unread,
Apr 28, 2022, 12:58:57 AM4/28/22
to Django users
okay i did both but now i am getting this error. Any clue on why?

SMTPSenderRefused at /password-reset/

(530, b'5.7.0 Authentication Required. Learn more at\n5.7.0 https://support.google.com/mail/?p=WantAuthError w137-20020a62828f000000b0050d2f9c3409sm14545822pfd.199 - gsmtp', 'webmaster@localhost')

ngal...@gmail.com

unread,
Apr 28, 2022, 1:11:45 AM4/28/22
to django...@googlegroups.com

I had the same issue before I resolve by Login to my Gmail account via browser on the same computer then go back to my project it works

Otherwise do the followings

i.             Allow access to less secure app for your Gmail account

ii.            Make sure you don’t send bulk emails, normally Gmail block your account if you send bulk emails

iii.           Debug to see if  os.environ.get(‘DB_USER’) and os.environ.get(‘DB_PASSWORD’) are your Gmail credentials (I thought dB refer to database credentials)

Vishesh Mangla

unread,
Apr 28, 2022, 1:32:56 AM4/28/22
to django...@googlegroups.com

Vishesh Mangla

unread,
Apr 28, 2022, 1:33:37 AM4/28/22
to django...@googlegroups.com

Vishesh Mangla

unread,
Apr 28, 2022, 1:35:18 AM4/28/22
to django...@googlegroups.com
I meant Gmail api.I was also stuck with Gmail.Also may 31 onwards Gmail will block all third party apps which simply login with email and password.

Antonis Christofides

unread,
Apr 28, 2022, 4:01:16 AM4/28/22
to django...@googlegroups.com

In my experience, Gmail does not allow (or does not support) using it as a smarthost if all you have is a free account, and even if you get it to work it will eventually cause you headaches. I don't know if this has changed the last few years, but I feel it hasn't. It's much better to use another service. I use runbox.com; mailbox.org is another solution. These are both paid email services. In a recent thread, someone also mentioned mailgun and sendgrid, which may be better suited for this purpose.

Other than that, you should enter a breakpoint or something in your code to verify that the values of EMAIL_HOST_USER and EMAIL_HOST_PASSWORD are what they should.

Regards,

Antonis

Gift Soko

unread,
Apr 28, 2022, 8:36:52 AM4/28/22
to Django users
Hi, You need to enable the less secure apps on your google account. following this article : https://devanswers.co/allow-less-secure-apps-access-gmail-account/

Hassan Bashir

unread,
Apr 29, 2022, 5:30:49 AM4/29/22
to django...@googlegroups.com
Hi there, 

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('DB_USER')
EMAIL_HOST_PASSWORD = os.environ.get('DB_PASSWORD')
in this code you just need to provide that email on which you will receive the email i means   that gmail account why you use the db user or db password ?
here the solution to receive emails like 
EMAIL_HOST_USER = exa...@gmail.com
EMAIL_HOST_PASSWORD = 12345678



Delvin Alexander

unread,
Apr 29, 2022, 3:16:45 PM4/29/22
to Django users
Good Afternoon,

i included the db_user and db_password becasue that was what my environment variable used in my advanced settings. When i debugged i did use both email user and db user and got the same result. Also i tried everyone's answer but still obtained the same result. Is it something i might have done wrong? I will try to rewatch the videos again but if someone has another try i can give then please inform me. i have been stuck for a while on this one. 

Hassan Bashir

unread,
May 1, 2022, 5:14:20 AM5/1/22
to django...@googlegroups.com
Hi Dear, 
Good Afternoon.
Dear these settings are used for only email host and password these variables are not valid for db_user or db_password. see the image below. Also make sure you smtp is enabled in that email which email you are using settings.py ok hope got this ?

Screenshot from 2022-05-01 14-07-14.png

Mahendra

unread,
May 1, 2022, 7:08:46 AM5/1/22
to django...@googlegroups.com
I Know this solution charges are applicable if you want?

Mahendra Yadav

--

Delvin Alexander

unread,
May 2, 2022, 12:33:04 AM5/2/22
to Django users
Improvements! i fixed my settings.py file and now i do not get the error. The only problem is that for my email, i do not get the email notification to reset my password. Any clues to this?

Mohammad Anarul

unread,
May 2, 2022, 1:36:53 AM5/2/22
to django...@googlegroups.com
EMAIL_HOST = smtp.gmail.com
EMAIL_HOST_USER = your-email
EMAIL_HOST_PASSWORD = your-email-password

EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_BACKEND = django.core.mail.backends.smtp.EmailBackend
DEFAULT_FROM_EMAIL = your-email

Antonis Christofides

unread,
May 2, 2022, 2:39:00 AM5/2/22
to django...@googlegroups.com

If some emails are emails are disappearing, you may get ideas on how to fix it from https://djangodeployment.com/2017/01/18/why-does-django-not-email-me-the-500-internal-server-error/

Reply all
Reply to author
Forward
0 new messages