Django won't send password-reset email on Linode server, works on local machine

I'm running a Django project on a Linode box. In my local_settings.py I have this:

###############
# EMAIL SETUP #
###############
ADMIN_EMAIL = "admin@richblockspoorblocks.com"
SUPPORT_EMAIL = "support@richblockspoorblocks.com"
DEFAULT_FROM_EMAIL = SUPPORT_EMAIL
SERVER_EMAIL = SUPPORT_EMAIL
EMAIL_HOST = 'mail.privateemail.com'
EMAIL_HOST_USER = DEFAULT_FROM_EMAIL
EMAIL_HOST_PASSWORD = 'my password here'
EMAIL_PORT = 465
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True

When I fill out and submit the form in Django's password_reset template, no email gets sent. Instead I see this in uwsgi.log.

MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Subject: Password reset on Default
From: webmaster@localhost
To: my.personal@gmail.com
Date: Wed, 16 May 2018 16:55:23 -0000
Message-ID: <20180516165523.3354.76044@rbpb-dev.richblockspoorblocks.com>



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/4w8-0373d185ce41dcdb0b63/

Your username: my.personal@gmail.com

Thank you.



-------------------------------------------------------------------------------

When I fillout the form and submit it when running my Django project on my local machine, I actually get an email at the gmail account specified.

What's going on here?

3 Replies

This is a long shot, but do you have threads enabled in UWSGI?

UWSGI Best Practices

Django isn't my wheelhouse but it's surprising to me that you can send email from your local machine to gmail without issue. Email is a very tricky thing and there are many many barriers enforced by providers in order to cut down on spam. Email will very commonly not work out of the box on any stock webserver, as email providers will require some basic configurations (usually DNS) proving you're a legitimate sender of email.

On a first look, your "From" address being "webmaster@localhost" is very likely to be something Google will filter as spam, so it looks like maybe your local_settings.py file isn't getting those variables referenced in your application. I would double check that this file is being pulled in properly.

In terms of DNS records you should also confirm you have the following:

  1. IPv4 and IPv6 rDNS (PTR) records
  2. SPF TXT record
  3. MX records

Here's a guide I've found that has more in-depth instructions for these points. Hope this helps!

Hey all, thanks for replying. Strange, but emails started sending correctly after I restart uwsgi.

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