|
@@ -1,4 +1,5 @@
|
|
|
import smtplib
|
|
|
+import warnings
|
|
|
|
|
|
try:
|
|
|
from email.mime.text import MIMEText
|
|
@@ -6,6 +7,10 @@ except ImportError:
|
|
|
from email.MIMEText import MIMEText
|
|
|
|
|
|
|
|
|
+class SendmailWarning(UserWarning):
|
|
|
+ """Problem happened while sending the e-mail message."""
|
|
|
+
|
|
|
+
|
|
|
class Message(object):
|
|
|
|
|
|
def __init__(self, to=None, sender=None, subject=None, body=None,
|
|
@@ -14,6 +19,7 @@ class Message(object):
|
|
|
self.sender = sender
|
|
|
self.subject = subject
|
|
|
self.body = body
|
|
|
+ self.charset = charset
|
|
|
|
|
|
if not isinstance(self.to, (list, tuple)):
|
|
|
self.to = [self.to]
|
|
@@ -60,6 +66,9 @@ def mail_admins(subject, message, fail_silently=False):
|
|
|
conf.EMAIL_HOST_USER,
|
|
|
conf.EMAIL_HOST_PASSWORD)
|
|
|
mailer.send(message)
|
|
|
- except Exception:
|
|
|
+ except Exception, exc:
|
|
|
if not fail_silently:
|
|
|
raise
|
|
|
+ warnings.warn(SendmailWarning(
|
|
|
+ "Mail could not be sent: %r %r" % (
|
|
|
+ exc, {"To": to, "Subject": subject})))
|