Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django 1.4.1 error reporting don't send me an email

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', '[email protected]'), # 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,
        },
    }
}
like image 809
WBAR Avatar asked Oct 22 '12 19:10

WBAR


2 Answers

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

ADMINS = (
    ('Your Name', '[email protected]'),
                                         *****
)

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...

like image 53
Felix Böhme Avatar answered Nov 09 '22 13:11

Felix Böhme


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

like image 43
Rohan Avatar answered Nov 09 '22 12:11

Rohan