Source code for superdjango.contrib.errors.backends.email

# Imports

from django.conf import settings
from django.core.mail import send_mail
from django.template import loader
from .base import ErrorHandler

# Exports

__all__ = (
    "Email",
)

# Constants

ERROR_CAPTURE_FROM_EMAIL = getattr(settings, "SUPERDJANGO_ERROR_CAPTURE_FROM_EMAIL", "webmaster@example.com")

# Classes


[docs]class Email(ErrorHandler): """Send email regarding an error.""" required_settings = [ "SUPERDJANGO_ERROR_CAPTURE_EMAILS", ]
[docs] def handle(self, report): """Send email to addresses defined in ``SUPERDJANGO_ERROR_CAPTURE_EMAILS``.""" body = self._parse_template("errors/email_body.txt") subject = self._parse_template("errors/email_subject.txt") send_mail(subject, body, ERROR_CAPTURE_FROM_EMAIL, settings.SUPERDJANGO_ERROR_CAPTURE_EMAILS) return None