Django MarkDown Mails


Keywords
django, mail, markdown
License
BSD-2-Clause
Install
pip install dmdm==2.0.2

Documentation

Django MarkDown Mail

PyPI version Tests pre-commit.ci status codecov Maintainability Code style: black

Write your email in markdown, and send them in txt & html.

Requirements

Install

python -m pip install dmdm

Usage

This replaces django's django.core.email.send_mail, but the mail will have an html alternative rendered from the text part with markdown. You can also provide a custom css and even images (that will be inlined) located in image_root.

from dmdm import send_mail

def send_mail(
    subject: str,
    message: str,
    from_email: str,
    recipient_list: List[str],
    context: Optional[Dict] = None,
    request: Optional[HttpRequest] = None,
    fail_silently: bool = False,
    css: Optional[str] = None,
    image_root: str = ".",
    auth_user: Optional[str] = None,
    auth_password: Optional[str] = None,
    connection: Optional[BaseEmailBackend] = None,
    reply_to: Optional[List[str]] = None,
) -> int

If you want to write your markdown in a template, just put the name of the template in message and add a context (which can be {}) and eventually a request:

send_mail(
    subject,
    "test_email_template.md",
    from_email,
    recipient_list,
    {"template_variable": "value"},
)