According to the documentation, if DEBUG
is set to False
and something is provided under the ADMINS
setting, Django will send an email whenever the code raises a 500 status code. I have the email settings filled out properly (as I can use send_mail fine) but whenever I intentionally put up erroneous code I get my 500.html template but no error email is sent. What could cause Django to not do this?
views:
349answers:
5Make sure your EMAIL_HOST and EMAIL_PORT are set up right in settings.py (these refer to your SMTP server). It might be assuming that you have an SMTP server running on localhost.
To test this locally, run Python's built-in test SMTP server:
python -m smtpd -n -c DebuggingServer localhost:1025
Then set these values in your settings.py
EMAIL_HOST='localhost'
EMAIL_PORT=1025
Trigger a 500 error, and you should see the e-mail appear in the python smtpd terminal window.
Try this
# ./manage shell
>>> from django.core.mail import send_mail
>>> send_mail('Subject here', 'Here is the message.', '[email protected]',['[email protected]'], fail_silently=False)
With a [email protected] that you actually get email at.
My web hosting provider - Webfaction - only allows emails to be sent From an email that has been explicitly created in the administrator panel. Creating one fixed the problem.
While likely not ideal, I have found using Gmail as the SMTP host works just fine. There is a useful guide at nathanostgard.com.
Feel free to post your relevant settings.py sections (including EMAIL_*, SERVER_EMAIL, ADMINS (just take out your real email), MANAGERS, and DEBUG) if you want an extra set of eyes to check for typos!