[Answered ]-Django errors not emailing

2👍

you can try this settings

#  FOR YOUR E-MAILS
DEFAULT_FROM_EMAIL='webmaster@localhost' # or webmaster@servername
SERVER_EMAIL='root@localhost' # or 'root@servername'
EMAIL_HOST = 'localhost' # or servername
EMAIL_HOST_USER='' # or 'user@gmail.com'
EMAIL_BACKEND ='django.core.mail.backends.smtp.EmailBackend'
EMAIL_PORT = 25 #587 
EMAIL_USE_TLS = True

0👍

Your settings should also contain a couple of lines for the logging purpose which sends mail when error occurs :

# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
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,
        },
    }
}

this is generated by django once you did

python manage.py startproject foobar

in your settings.py

You can have a look at it here https://docs.djangoproject.com/en/1.4/topics/logging/

Hope this will help .

Leave a comment