diff options
Diffstat (limited to 'postgresqleu/mailqueue/util.py')
-rw-r--r-- | postgresqleu/mailqueue/util.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/postgresqleu/mailqueue/util.py b/postgresqleu/mailqueue/util.py index c075e458..f2a66ced 100644 --- a/postgresqleu/mailqueue/util.py +++ b/postgresqleu/mailqueue/util.py @@ -11,22 +11,26 @@ from django.template.loader import get_template from models import QueuedMail + def template_to_string(templatename, attrs={}): context = {} context.update(attrs) context.update(settings_context()) return get_template(templatename).render(context) + def send_template_mail(sender, receiver, subject, templatename, templateattr={}, attachments=None, bcc=None, sendername=None, receivername=None): send_simple_mail(sender, receiver, subject, template_to_string(templatename, templateattr), attachments, bcc, sendername, receivername) + def _encoded_email_header(name, email): if name: return formataddr((str(Header(name, 'utf-8')), email)) return email + def send_simple_mail(sender, receiver, subject, msgtxt, attachments=None, bcc=None, sendername=None, receivername=None): # attachment format, each is a tuple of (name, mimetype,contents) # content should be *binary* and not base64 encoded, since we need to @@ -49,13 +53,13 @@ def send_simple_mail(sender, receiver, subject, msgtxt, attachments=None, bcc=No encoders.encode_base64(part) msg.attach(part) - # Just write it to the queue, so it will be transactionally rolled back QueuedMail(sender=sender, receiver=receiver, fullmsg=msg.as_string()).save() # Any bcc is just entered as a separate email if bcc: QueuedMail(sender=sender, receiver=bcc, fullmsg=msg.as_string()).save() + def send_mail(sender, receiver, fullmsg): # Send an email, prepared as the full MIME encoded mail already QueuedMail(sender=sender, receiver=receiver, fullmsg=fullmsg).save() |