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 = "firstname.lastname@example.org" SUPPORT_EMAIL = "email@example.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
MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: Password reset on Default From: webmaster@localhost To: firstname.lastname@example.org Date: Wed, 16 May 2018 16:55:23 -0000 Message-ID: <email@example.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: firstname.lastname@example.org 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?
This is a long shot, but do you have threads enabled in UWSGI?
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:
- IPv4 and IPv6 rDNS (PTR) records
- SPF TXT record
- MX records
Hey all, thanks for replying. Strange, but emails started sending correctly after I restart uwsgi.