# I can send “reset password” mail but cannot use the “send\_mail”

**URL:** <https://forum.djangoproject.com/t/i-can-send-reset-password-mail-but-cannot-use-the-send-mail/8194>\
**Category:** Using Django\
**Created:** [June 3, 2021, 6:56am UTC](https://forum.djangoproject.com/t/i-can-send-reset-password-mail-but-cannot-use-the-send-mail/8194 "2021-06-03T06:56:58Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jakobhenningjensen](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/jakobhenningjensen/32/3751_2.png) [@Jakobhenningjensen](https://forum.djangoproject.com/u/Jakobhenningjensen)\
**Post date:** [June 3, 2021, 6:56am UTC](https://forum.djangoproject.com/t/i-can-send-reset-password-mail-but-cannot-use-the-send-mail/8194/1 "2021-06-03T06:56:58Z")

</div>

I want to send a “greetings” mail, when people sign up for my webpage.

I can send a “reset password” email using the built in `auth_views.PasswordResetView` but when I try use the `django.core.mail.send_mail` I get an `Username and Password not accepted.`

My `settings.py`

```python
.
.
#Email config
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' 
EMAIL_USE_TLS = True
EMAIL_PORT = 587
DEFAULT_FROM_EMAIL = "My Name <no-reply@my_site.com>"
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_PASSWORD = app_cred
EMAIL_HOST_USER = app_email

```

and `views.py`

```python
def register(request):
    if request.method=="POST": #post request
        form = UserRegisterForm(request.POST)
        agree_form = AgreeForm(request.POST)
        if form.is_valid() and agree_form.is_valid():
            user = form.save(commit=False)
            user.email = form.cleaned_data["email"]
            user.save()
            
            send_mail(subject = "Welcome to my-site.com",
            message = "Welcome!",
            from_email = None,
            recipient_list = [user.email])
            return redirect("login")
    else:
        form = UserRegisterForm()
        agree_form = AgreeForm()

    return render(request,"users/register.html",context= {"form":form,"agree_form":agree_form})

```

As far as I understand, Django uses the credentials specified in the settings, so I wonder why I can send a password-reset mail but cannot use the `send_mail` method using the same credentials?

---

<div class="post-metadata">

**Author:** ![nemecek\_f](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/nemecek_f/32/668_2.png) [@nemecek\_f](https://forum.djangoproject.com/u/nemecek_f)\
**Post date:** [June 3, 2021, 7:03am UTC](https://forum.djangoproject.com/t/i-can-send-reset-password-mail-but-cannot-use-the-send-mail/8194/2 "2021-06-03T07:03:51Z")

</div>

Hello, did you check your Gmail account if there is any alert from Google regarding sending emails?

---

<div class="post-metadata">

**Author:** ![Jakobhenningjensen](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/jakobhenningjensen/32/3751_2.png) [@Jakobhenningjensen](https://forum.djangoproject.com/u/Jakobhenningjensen)\
**Post date:** [June 3, 2021, 7:17am UTC](https://forum.djangoproject.com/t/i-can-send-reset-password-mail-but-cannot-use-the-send-mail/8194/3 "2021-06-03T07:17:12Z")

</div>

No alerts/emails at all

---

<div class="post-metadata">

**Author:** ![nemecek\_f](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/nemecek_f/32/668_2.png) [@nemecek\_f](https://forum.djangoproject.com/u/nemecek_f)\
**Post date:** [June 3, 2021, 8:39am UTC](https://forum.djangoproject.com/t/i-can-send-reset-password-mail-but-cannot-use-the-send-mail/8194/4 "2021-06-03T08:39:55Z")

</div>

This is funny coincidence. I just found out that my “greetings” email for new project works, but those for resetting password don’t ☹

I’ll let you know once I fix this where the problem was

---

<div class="post-metadata">

**Author:** ![nemecek\_f](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/nemecek_f/32/668_2.png) [@nemecek\_f](https://forum.djangoproject.com/u/nemecek_f)\
**Post date:** [June 3, 2021, 8:59am UTC](https://forum.djangoproject.com/t/i-can-send-reset-password-mail-but-cannot-use-the-send-mail/8194/5 "2021-06-03T08:59:38Z")

</div>

So, found it 😃 I am using email as a `username` but the reset password feature uses the `email` field on the user. So I needed to populate the `email` field as well.

---

<div class="post-metadata">

**Author:** ![Jakobhenningjensen](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/jakobhenningjensen/32/3751_2.png) [@Jakobhenningjensen](https://forum.djangoproject.com/u/Jakobhenningjensen)\
**Post date:** [June 3, 2021, 9:01am UTC](https://forum.djangoproject.com/t/i-can-send-reset-password-mail-but-cannot-use-the-send-mail/8194/6 "2021-06-03T09:01:02Z")

</div>

My error is regarding the from\_email and not the to\_email, unfortunately (I’m using email as username aswell)

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [June 3, 2021, 12:22pm UTC](https://forum.djangoproject.com/t/i-can-send-reset-password-mail-but-cannot-use-the-send-mail/8194/7 "2021-06-03T12:22:45Z")

</div>

If the `from_email` isn’t the same name as the credentials being used, is that name “registered” with gmail as being authorized to be sent from that account? (gmail doesn’t allow the use of arbitrary `from` addresses)

---

<div class="post-metadata">

**Author:** ![Jakobhenningjensen](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/jakobhenningjensen/32/3751_2.png) [@Jakobhenningjensen](https://forum.djangoproject.com/u/Jakobhenningjensen)\
**Post date:** [June 3, 2021, 1:05pm UTC](https://forum.djangoproject.com/t/i-can-send-reset-password-mail-but-cannot-use-the-send-mail/8194/8 "2021-06-03T13:05:56Z")

</div>

What happend was, that I had recently changed my password, and for some reason, that removed my app-passwords in gmail i.e the credentials was purely wrong
