send_mail wrapper with DEBUG email trapping

1
2
3
4
5
6
7
8
from django.core.mail import send_mail as django_send_mail
from django.conf import settings

def send_mail(subject, message, from_email, recipient_list, fail_silently=False, auth_user=None, auth_password=None, connection=None):
    if settings.DEBUG:
        message = "%s\n\n=========== DEBUG Email Intercepted =============\nOriginal Recipients: %s" % (message, ",".join(recipient_list))
        recipient_list = [settings.SERVER_EMAIL]
    django_send_mail(subject, message, from_email, recipient_list, fail_silently=False, auth_user=None, auth_password=None, connection=None)

More like this

  1. Testing Email Registration by osborn.steven 4 years, 3 months ago
  2. ReportBug() with tons of debug in mail by sleepycal 2 years, 8 months ago
  3. Debug Page Load Time Stats Middleware by udfalkso 5 years, 10 months ago
  4. Email queue in DB by fish2000 3 years, 2 months ago
  5. Unfuddle-style post-commit emails - tied to a specific Django project. by jsandell 4 years, 9 months ago

Comments

(Forgotten your password?)