Django, custom SMTP server for logging

One of my client uses google apps, so I use that account to send out mails with Django, which works just fine. However, google silently drops all error mails to the admins, for whatever reason you can't debug and will never hear anything about anyway. As those mails only go to the dev team it doesn't really matter which mailserver is used, so I decided to write my own email handler. To use it add it to the LOGGING settings like you would the normal AdminEmailHandler and add the necessary settings to your configuration.

from django.conf import settings
from django.core.mail import get_connection
from django.utils.log import AdminEmailHandler

class MyAdminEmailHandler(AdminEmailHandler):
    Use a custom handler because gmail sucks...
    def connection(self):
        return get_connection(
Published on Dec. 9, 2016 at 5:01 p.m. by Nicolas . You can follow the discussion with the comment feed for this post. Feeling generous? Donate!


Start a new thread

Cancel reply
Markdown. Syntax highlighting with <code lang="php"><?php echo "Hello, world!"; ?></code> etc.