Django Email Error Reporting Not Working
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of django mail_admins this site About Us Learn more about Stack Overflow the company Business
Django Adminemailhandler
Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask django error reporting mail Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up django error emails not sending Django not sending emails to admins up vote 46 down vote favorite 4 According to the documentation, if DEBUG is set to False and something is provided under the ADMINS setting, Django will send an email whenever the code raises a 500 status code. I have the email settings filled out properly (as I can use send_mail fine) but whenever I intentionally put
Django Admins
up erroneous code I get my 500.html template but no error email is sent. What could cause Django to not do this? python django share|improve this question asked Sep 12 '09 at 2:57 JoseVega add a comment| 15 Answers 15 active oldest votes up vote 68 down vote In my case the cause was missing SERVER_EMAIL setting. The default for SERVER_EMAIL is root@localhost. But many of email servers including my email provider do not accept emails from such suspicious addresses. They silently drop the emails. Changing the sender email address to django@my-domain.com solved the problem. In settings.py: SERVER_EMAIL = 'django@my-domain.com' share|improve this answer edited Mar 28 '14 at 17:07 Radek Simko 3,526124390 answered Jul 1 '11 at 17:54 geekQ 16.9k63341 2 Another hint that this is likely the problem is if you check your mail log and see an entry containing sender non-delivery notification. –jathanism Jun 25 '12 at 16:58 that worked for me!! –azuax Mar 12 '15 at 15:07 add a comment| up vote 31 down vote Another possibility for error is trouble with your ADMINS setting. The following setting will cause th
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about django 500 internal server error Stack Overflow the company Business Learn more about hiring developers or posting ads with django exceptionreporter us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is
Django Raise 500
a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Django not sending error emails - how can I debug? up vote 2 http://stackoverflow.com/questions/1414130/django-not-sending-emails-to-admins down vote favorite I'm using Django 1.8. This is my base settings file: 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, }, } } ADMINS = ( ('ME', 'me@gmail.com'), ) MANAGERS = ADMINS And these are my production settings: ########## EMAIL http://stackoverflow.com/questions/31987569/django-not-sending-error-emails-how-can-i-debug CONFIGURATION EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_USE_TLS = True EMAIL_HOST = 'smtp.gmail.com' EMAIL_PORT = 587 EMAIL_HOST_USER = 'my.error.account@gmail.com' EMAIL_HOST_PASSWORD = utils.get_env_setting('GMAIL_PASS') EMAIL_SUBJECT_PREFIX = '[%s] ' % SITE_NAME SERVER_EMAIL = EMAIL_HOST_USER DEFAULT_FROM_EMAIL = EMAIL_HOST_USER ########## END EMAIL CONFIGURATION It used to send error email in production, but has stopped. I've set up a page that returns 500 errors so that I can test this further - no emails being sent when I load it. I've tried debugging the obvious things: I can still log into my.error.account@gmail.com and it doesn't seem to have been blocked. I've checked my spam filter. I'm certain that DEBUG is set false. I believe the GMAIL_PASS environment variable is available to the Django user. How can I debug this further? python django share|improve this question asked Aug 13 '15 at 11:57 Richard 10.8k30102187 1 First, check that mails are being sent. Set the HOST to localhost, the PORT to 1025, disable TLS and run a dummy SMTP server using this command: python -m smtpd -n -c DebuggingServer localhost:1025 –zopieux Aug 13 '15 at 12:02 add a comment| 1 Answer 1 active oldest votes up vote 0 down vote For the debugging part of the question @zopieux commented: First, check that mails are being sent. Set: EMA
van GoogleInloggenVerborgen veldenZoeken naar groepen of berichten
Score: 5 (after 5 ratings) Download Raw The default traceback sent by email when an error occurs, usually gives too little information comparing it to the error page in the DEBUG mode. This snippet guerilla-patches error handling and sends by email the same information as you would see in DEBUG mode. To set it up, add the snippet to any models.py of an installed app. (I wonder why this hasn't been implemented in the core) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46# -*- coding: UTF-8 -*- from django.core.handlers.base import BaseHandler def _handle_uncaught_exception(self, request, resolver, exc_info): """ Processing for any otherwise uncaught exceptions (those that will generate HTTP 500 responses). Can be overridden by subclasses who want customised 500 handling. Be *very* careful when overriding this because the error could be caused by anything, so assuming something like the database is always available would be an error. """ from django.conf import settings from django.core.mail.message import EmailMessage from django.views import debug if settings.DEBUG_PROPAGATE_EXCEPTIONS: raise technical_500_response = debug.technical_500_response(request, *exc_info) if settings.DEBUG: return technical_500_response # When DEBUG is False, send an error message to the admins. subject = 'Error (%s IP): %s' % ((request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS and 'internal' or 'EXTERNAL'), request.path) msg = EmailMessage( settings.EMAIL_SUBJECT_PREFIX + subject, technical_500_response.content, settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS], ) msg.content_subtype = "html" # Main content is now text/html msg.send(fail_silently=True) # If Http500 handler is not installed, re-raise last exception if resolver.urlconf_module is None: raise exc_info[1], None, exc_info[2] # Return an HttpResponse that displays a friendly error message. callback, param_dict = resolver.resolve500() return callback(request, **param_dict) BaseHandler.handle_uncaught_ex