Okay. So I am really not happy with that I am probably posting another duplicate question, but nothing relevant seems to help me.
So the problem is that I want to receive emails containing server error messages (500), and I don't.
What do I know:
- Everything works just fine on my local machine: I get my messages when I set
DEBUG = False
. Too many of them, being honest. - Calling
django.core.mail.mail_admins()
from within./manage.py shell
on production server is working fine: I get my emails, as I get those that are sent bysend_email()
from within a view - I have
DEBUG = False
set on my production server - I am trying to get email by messing up my home template with missing parentheses and also by putting
assert 0
string into my home view. I am getting my 500.html rendered alright with that. Here are my email settings in settings.py:
EMAIL_HOST = 'smtp.yandex.ru' EMAIL_HOST_USER = 'noreply@<project-name>.ru' EMAIL_HOST_PASSWORD = '<password>' EMAIL_PORT = 587 EMAIL_USE_TLS = True DEFAULT_FROM_EMAIL = 'noreply@<project-name>.ru' SERVER_EMAIL = 'noreply@<project-name>.ru'
- Here are my logging settings in settings.py:
LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'filters': { 'require_debug_false': { '()': 'django.utils.log.RequireDebugFalse', } }, 'handlers': { 'mail_admins': { 'level': 'ERROR', 'filters': ['require_debug_false'], 'class': 'django.utils.log.AdminEmailHandler' } }, 'loggers': { 'django': { 'handlers': ['mail_admins'], 'level': 'ERROR', 'propagate': False, }, } }
I also tried changing 'propagate' to True, but didn't succeed
- And here is my ADMINS from settings.py:
ADMINS = (('xelnod', 'xelnod@gmail.com'),)
- I am using Django 1.7 with Python 2.7.6
- And the production server is running on '57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux'
- I was here:
https://stackoverflow.com/questions/1414130/,
and here: https://stackoverflow.com/questions/17374909/,
and even here: https://stackoverflow.com/questions/19634962/ (so I did runsudo apt-get install sendmail
already),
and in some other places — unfortunately, no luck with that.
…am I missing something (I bet it would be something very stupid…)?
UPD: I noticed that I only receive email messages concerning my static files when I test this on my local — nothing about broken template or AssertionError, so, I guess, it must be something with my error level or my 500 errors are not bad enough for Django to email them… Tried setting handler and logger levels to INFO, but nothing changed