# My email password reset functionality not working

**URL:** <https://forum.djangoproject.com/t/my-email-password-reset-functionality-not-working/39159>\
**Category:** Mystery Errors\
**Created:** [February 26, 2025, 11:51pm UTC](https://forum.djangoproject.com/t/my-email-password-reset-functionality-not-working/39159 "2025-02-26T23:51:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Meshack7862](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/meshack7862/32/27164_2.png) [@Meshack7862](https://forum.djangoproject.com/u/Meshack7862)\
**Post date:** [February 26, 2025, 11:51pm UTC](https://forum.djangoproject.com/t/my-email-password-reset-functionality-not-working/39159/1 "2025-02-26T23:51:51Z")

</div>

Hi everyone,

I’m facing an issue with Django’s password reset functionality using Gmail’s SMTP server. Despite following best practices, I’m getting authentication errors (`535 5.7.8 Username and Password not accepted`). I’d appreciate guidance from anyone who has overcome similar Gmail restrictions.

What I’ve Tried:

1. Generated a 16-digit **app-specific password** (2-Step Verification enabled)
2. Tested both ports `587 (TLS)` and `465 (SSL)`
3. Approved device via [Google’s Unlock Captcha](https://accounts.google.com/DisplayUnlockCaptcha)
4. Verified credentials work in standalone Python scripts but fail in Django

Configuration in python settings.py:  
EMAIL\_BACKEND = ‘django.core.mail.backends.smtp.EmailBackend’  
EMAIL\_HOST = ‘[smtp.gmail.com](http://smtp.gmail.com)’  
EMAIL\_PORT = 587  
EMAIL\_USE\_TLS = True  
EMAIL\_HOST\_USER = ‘myapp@gmail.com’ # Actual email replaced  
EMAIL\_HOST\_PASSWORD = ‘app-specific-password’

Error Log:  
smtplib.SMTPAuthenticationError: (535, b’5.7.8 … BadCredentials …')

1. Are there **Android-specific SMTP quirks** I’m missing (testing on Pydroid 3)?
2. Should I switch to **alternative email providers** (e.g., Mailgun, SendGrid)?
3. Could Google be blocking **“less secure apps”** despite app passwords?

Any insights or workarounds would be invaluable! I’m happy to share sanitized code/config snippets if needed.

Note:I’ve redacted sensitive credentials above.

---

<div class="post-metadata">

**Author:** ![medmunds](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/medmunds/32/22140_2.png) [@medmunds](https://forum.djangoproject.com/u/medmunds)\
**Post date:** [February 27, 2025, 2:08am UTC](https://forum.djangoproject.com/t/my-email-password-reset-functionality-not-working/39159/2 "2025-02-27T02:08:02Z")

</div>

Those settings seem fine.

(Or at least, I was able to send email from Django through Gmail using those settings, with a freshly-created Gmail [app password](https://support.google.com/mail/answer/185833), and using Django’s [sendtestemail](https://docs.djangoproject.com/en/5.1/ref/django-admin/#sendtestemail) management command.)

Since you say the credentials work in other scripts but not in Django, I would look at how your app is getting those settings. You could temporarily add a print() in your settings.py to check EMAIL\_HOST\_PASSWORD and \_USER are what you expect.

Are you maybe using an env file? If so, a common source of credentials errors is trying to use end-of-line `# comments`. Many env file readers don’t support that, so the comment gets included as part of the settings value.

> [@Meshack7862](#):
>
> Should I switch to **alternative email providers** (e.g., Mailgun, SendGrid)?

For initial testing or a small personal project sending a few emails, Gmail is probably fine. For anything more, you should find an alternative. If you email too many different recipient addresses, Google will think you might be sending spam and disable your account. (Their threshold for “too many” has changed over time, and I can’t give you an exact number.)

---

<div class="post-metadata">

**Author:** ![Meshack7862](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/meshack7862/32/27164_2.png) [@Meshack7862](https://forum.djangoproject.com/u/Meshack7862)\
**Post date:** [February 27, 2025, 10:26pm UTC](https://forum.djangoproject.com/t/my-email-password-reset-functionality-not-working/39159/3 "2025-02-27T22:26:14Z")

</div>

Ok let me try newly generate app password and sendtestmail
