Receive Email Notification on Server Error in Django
Django provides an excellent built-in feature of sending email to the administrator whenever a server error occurs. The email is sent to the users listed in ADMINS variables whenever your code raises an unhandled exception and results in an internal server error (HTTP status code 500).
Emails are sent via. Django’s logging framework. The default LOGGING configuration is enough to receive email which looks similar to code below:
You need to define a few variables in settings.py to make sure you receive email.
Define SERVER_EMAIL and ADMINS variable
Define name and email of all your administrator in ADMINS variable as a tuple.
Also make sure that you have defined SERVER_EMAIL variable. Otherwise, the mail will be sent via. root@localhost and your mail client may block it.
With your default settings, you will now receive email as well as complete log on your email.
You can also receive email on 404 errors. I usually avoid this as it would flood my email. Complete details can be found on Django’s official page on error reporting.