Skip to main content

Django mail mixins and utilities

Project description

=================
django-mail-utils
=================

Django mail mixins and utilities.

Contents
========
TemplateMessageMixin
--------------------
The mixin allows to create email body from a template (any text file).

| ``template_name`` - a path to a template in one of TEMPLATE_DIRs.
| ``template_context`` - a dictionary of variables passed to a template.

Both ``template_name`` and ``template_context`` can be set in inherited classes or
updated from constructor parameters.

Also you can pass the template string like the constructor's ``body`` parameter.
Then it will be used to render the real email's body.

EnvelopedMessageMixin
---------------------
The mixin allows to predefine email parameters ``subject``, ``from_email``, ``to``,
``cc`` and ``bcc``.

Parameters may be overridden via ``__init__``.


Installation
============
::

pip install django-mail-utils
::


Examples
========

TemplateMessageMixin
--------------------
::

from mail_utils.messages import TemplateMessageMixin

class RegistrationEmailMessage(TemplateMessageMixin, EmailMessage):
template_name = 'emails/registration.html'
template_context = {'from': 'Acme Corporation'}
::

EnvelopedMessageMixin
---------------------
::

from mail_utils.messages import EnvelopedMessageMixin

class NotificationEmailMessage(EnvelopedMessageMixin, EmailMessage):
subject = 'Admin News'
from_email = ADMIN_EMAIL
to = COLLEGUES_EMAILS
cc = CC_EMAILS
bcc = BCC_EMAILS
::

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-mail-utils-0.2.1.tar.gz (2.3 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page