Package: django-mail-template
Django Mail TemplateA very simple Django application for:Providebasic templatefeatures for mails subjects and bodies.Provide needed infrastructure to let administrative users create/edit mails
used by applications.Descriptiondjango_mail_templateis a very simple application to create mails templates
with context variables, and then send mails with context variables replaced
with values. Mails templates are created withDjango admin interface.For example, if context variables are:first_nameandlast_name, while
cycling a collection of people (clients, providers, and like) is possible to
send a mail to each of them using their first name and last name to replace
the context variables inMailTemplatebody or subject:Dear {first_name} {last_name} have a great new year!!!Also with indirect use betweenMailTemplateandConfigurationis
possible to change at run time the mail template mapped to a piece of code
through aConfigurationinstance.For example, create two mail template: one with christmas greeting text
and subject, and other mail template with new year greeting text and subject.
Then the same process (code) used in upper example can be used to send
christmas and new year greeting to all people.Change which mail template is used by which process inDjango admin
interface.Works with:Django 1.11+ (Python 3.5+)Django 2+ (Python 3.5+)Django 3+ (Python 3.5+)DocumentationRequirementsDjango's email docs specify all requirements for sending mail with
django.core.mail (Django email).django_mail_templateusesDjango admin site, check official
documentation for it's requirements:Django admin site.django_mail_templateusesDjango CKEditorto let write rich text
MailTeamplate.Quick startInstallation and configurationInstalldjango_mail_templatefrom pypi:pip install django-mail-templateAdd'django_mail_template'and'ckeditor'to yourINSTALLED_APPSsetting:INSTALLED_APPS = [
        ...
        'ckeditor'
        'django_mail_template',
    ]Run migrations to createdjango_mail_templatemodels:python manage.py migrateRun the collectstatic management command:python manage.py collectstaticUse Django Mail Template1. Direct useYou can simple usedjango_mail_templateto send mails:from django_mail_template.models import MailTemplate

    mail_template = MailTemplate(title="A mail Title", from="a@b.com",
                                 to="b@b.com",
                                 subject="Django Mail Template quick start.")
    mail_template.send()2. Template featuresdjango_mail_template'sbasic templatefeature is based in variables
replacement with Python string format:from django_mail_template.models import MailTemplate

    ...
    mail_template = MailTemplate.create(
        title="First mail template",
        from="a@b.com",
        subject="Hello {client}.",
        body="Dear {client}: We are delivering your {product}."
    )

    ...
    mail_template.to = ["bobtheclient@c.com"]
    mail_template.send({"client": "Bob TheClient",
                        "product": "Great product"})Administrative users can create or editMailTemplateusingDjango admin
siteand redact text using Python string format.3. Indirect useIs also possible to use an indirect call throughConfigurationdata model.
InDjango admin site(or by code) you can create:a_mail_template_greeting = MailTemplate.objects.create(
        title="First mail template",
        from="a@b.com",
        subject="Hello {client}.",
        body="Dear {client}: We wish you {greeting}.")

    configuration = Configuration.objects.create(
        process="clients_greeting",
        mail_template=a_mail_template_greeting
    )Then in codefrom django_mail_template.models import Configuration

    mail_template = Configuration.get_mail_template("clients_greeting")
    # Cycle through clients
        mail_template.to = client.email
        mail_template.send({"client": client.name,
                            "greeting": "A great mew year!!!"})4. Django admin interfaceWhendjango_mail_templateis installed, and migrations applied,Django
admin sitewill expose to administrative users a new section with titleDjango Mail Template. User can manageMailTempaltesandConfigurationsfrom there:MailTemplate: Users can redact mails (create, edit, delete).Configuration: If code points toConfigurations(indirect use),
administrative users can change mappedMailTemplateto use new mail
template without changing code.Test createdmail templatesMore about Django mail templateYou can check thedjango_mail_templatetest execution atTravis CI integration()You can also checkdjango_mail_templatetest coverage atCoverage()Related sitesDocumentationPackage at pypi.orgsource codeTravis CI integrationCodecov