Author: leidel
Date: Tue Jan 20 11:38:17 2009
New Revision: 56
Modified:
trunk/docs/usage.txt
trunk/mailer/__init__.py
trunk/mailer/management/__init__.py
Log:
Removed non-functional monkey patch and added mail_managers method
Modified: trunk/docs/usage.txt
==============================================================================
--- trunk/docs/usage.txt (original)
+++ trunk/docs/usage.txt Tue Jan 20 11:38:17 2009
@@ -11,7 +11,7 @@
Putting Mail On The Queue
=========================
-Because django-mailer currently uses the same function signature as
django's
+Because django-mailer currently uses the same function signature as
Django's
core mail support you can do the following in your code::
# favour django-mailer but fall back to django.core.mail
@@ -20,19 +20,18 @@
except ImportError:
from django.core.mail import send_mail
-and then just call send_mail like you normally would in django::
+and then just call send_mail like you normally would in Django::
send_mail(subject, message_body, settings.DEFAULT_FROM_EMAIL,
recipients)
-You can have Django use the mailer for crash e-mails if you add the
following
-to your settings.py file::
+Additionally you can send all the admins as specified in the ``ADMIN``
+setting by calling::
- MAILER_FOR_CRASH_EMAILS = True
+ mail_admins(subject, message_body)
-This can help when you have a large number of crashes occurring, as the
-default mail_admins will bring the site to a crawl posting the mail
messages
-to the SMTP server. It will also give you a chance to purge excessive crash
-e-mails before they are sent.
+or all managers as defined in the ``MANAGERS`` setting by calling::
+
+ mail_managers(subject, message_body)
Clear Queue With Command Extensions
===================================
Modified: trunk/mailer/__init__.py
==============================================================================
--- trunk/mailer/__init__.py (original)
+++ trunk/mailer/__init__.py Tue Jan 20 11:38:17 2009
@@ -42,3 +42,14 @@
subject=settings.EMAIL_SUBJECT_PREFIX +
force_unicode(subject),
message_body=message,
priority=priority).save()
+
+def mail_managers(subject, message, fail_silently=False,
priority="medium"):
+ from django.conf import settings
+ from mailer.models import Message
+ priority = PRIORITY_MAPPING[priority]
+ for name, to_address in settings.MANAGERS:
+ Message(to_address=to_address,
+ from_address=settings.SERVER_EMAIL,
+ subject=settings.EMAIL_SUBJECT_PREFIX +
force_unicode(subject),
+ message_body=message,
+ priority=priority).save()
Modified: trunk/mailer/management/__init__.py
==============================================================================
--- trunk/mailer/management/__init__.py (original)
+++ trunk/mailer/management/__init__.py Tue Jan 20 11:38:17 2009
@@ -1,5 +0,0 @@
-from django.conf import settings
-
-if getattr(settings, 'MAILER_FOR_CRASH_EMAILS', False):
- from django.core.handlers import base
- base.mail_admins = mail_admins
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pinax-updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/pinax-updates?hl=en
-~----------~----~----~----~------~----~------~--~---