7

This question is probably a duplicated question and sorry about that.

I'm using Django 1.4.1 and on production server I set DEBUG to False. Sometimes users get an Exception and server shows 500.html template but don't send an email configured in ADMINS section of settings.py.

In application sending email is properly configured because under registration process I can receive Welcome Email.

Fragment of my settings.py:

DEBUG = False
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    ('example', 'example@example.com'), # this changed but my email is correct
)

MANAGERS = ADMINS

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
    'django.middleware.transaction.TransactionMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
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.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': True,
        },
    }
}
WBAR
  • 4,924
  • 7
  • 47
  • 81
  • what is your server setup? the error might be happening before you hit the application server, meaning that django doesn't get the opportunity to send the mail – Timmy O'Mahony Oct 22 '12 at 19:57
  • @TimmyO'Mahony Problem (Exception) is raised deep in business logic (inside VIEW function) and Django corretly serves 500.html template – WBAR Oct 22 '12 at 20:21
  • 1
    I know it's a dumb question but you'd be surprised. Did you check your spam folder ? – Paulo Oct 22 '12 at 23:45
  • Have you added mail settings, ie the smtp server to use and the settings for that? – zsquare Oct 24 '12 at 10:12
  • in my question: `In application sending email is properly configured because under registration process I can receive Welcome Email.` – WBAR Oct 24 '12 at 14:05
  • possible duplicate of [Django not sending emails to admins](http://stackoverflow.com/questions/1414130/django-not-sending-emails-to-admins) – Vanni Totaro May 16 '15 at 21:15

2 Answers2

10

This has been driving me mad for a while now. JUST figured it out:

ADMINS = (
    ('Your Name', 'your_email@example.com'),
                                         *****
)

That comma at the end was all I forgot and it was enough to break it. Thought I'd share it so some other poor idiot like me can save himself some precious hair that he might otherwise have pulled out...

Felix Böhme
  • 508
  • 5
  • 12
9

Did you set SERVER_EMAIL in settings. Thats the from address used to send out error mails. Default is root@localhost which might be getting blocked at SMTP. Might want to set it the same as DEFAULT_FROM_EMAIL

Rohan
  • 1,031
  • 7
  • 10