Password reset in Django on nginx server writes to log file instead of sending email

I have a Django app running on a server with uWSGI and nginx.

In my local_settings.py file I have this:

###############
# EMAIL SETUP #
###############
EMAIL_HOST = 'smtp.privateemail.com'
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = 'MY EMAIL PASSWORD'
EMAIL_PORT = 465
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True


########################
# OTHER EMAIL SETTINGS #
########################
ADMIN_EMAIL = "[email protected]"
SUPPORT_EMAIL = "[email protected]"

When I fill out the /password_reset/ template with an email and submit the form, the address I enter gets no password-reset message. Nothing is logged to error.log. Here's what I see in uwsgi.log

[pid: 3354|app: 0|req: 1489/2206] 73.49.35.42 () {44 vars in 948 bytes} [Mon May 14 16:59:06 2018] GET /login-register/ => generated 7480 bytes in 39 msecs (HTTP/1.1 200) 3 headers in 102 bytes (2 switches on core 0)
[pid: 3355|app: 0|req: 718/2207] 73.49.35.42 () {44 vars in 994 bytes} [Mon May 14 16:59:14 2018] GET /password_reset/ => generated 3669 bytes in 38 msecs (HTTP/1.1 200) 4 headers in 256 bytes (1 switches on core 0)
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Subject: Password reset on Default
From: [email protected]
To: [email protected]
Date: Mon, 14 May 2018 16:59:16 -0000
Message-ID: <[email protected]>



Hello,

You received this email because a request was made to reset the password.


If you requested this, go to the following page and choose a new password: https://127.0.0.1:8000/reset/MQ/4w6-efc1272e976075dfd881/

Your username: MyUsername

Thank you.



-------------------------------------------------------------------------------
[pid: 3354|app: 0|req: 1490/2208] 73.49.35.42 () {52 vars in 1194 bytes} [Mon May 14 16:59:16 2018] POST /password_reset/ => generated 0 bytes in 22 msecs (HTTP/1.1 302) 4 headers in 138 bytes (1 switches on core 0)
[pid: 3355|app: 0|req: 719/2209] 73.49.35.42 () {46 vars in 1035 bytes} [Mon May 14 16:59:16 2018] GET /password_reset/done/ => generated 2877 bytes in 40 msecs (HTTP/1.1 200) 3 headers in 102 bytes (1 switches on core 0)

What must I change so that Django will email the email I input in the /password_reset template?

1 Reply

Theres a few possibilities here.

Are you absolutely sure EMAIL_BACKEND is not 'django.core.mail.backends.console.EmailBackend' ? That could cause the behavior you are observing.

There may also be a bug in your password_reset view. You may want to make sure your calls to send_email() do not pass fail_silently=True

I would also try removing the EMAIL_BACKEND setting: it should default to the one you want as long as you are providing the correct host/port/etc.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct