Skip to main content

Django MarkDown Mails

Project description

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"},
)

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

dmdm-2.0.3.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

dmdm-2.0.3-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file dmdm-2.0.3.tar.gz.

File metadata

  • Download URL: dmdm-2.0.3.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.10.6 Linux/5.15.0-1031-azure

File hashes

Hashes for dmdm-2.0.3.tar.gz
Algorithm Hash digest
SHA256 b3be786df928d5a591868240d698a6579f4ef4cfbd2d5c3c07d13687c82cb5f2
MD5 e7d5d9b6eec3c8d1731a893dcd563d05
BLAKE2b-256 f73e5265900a5cdc26a778138ca40e394fed7277bb70e1840d5123ec9d67c10f

See more details on using hashes here.

File details

Details for the file dmdm-2.0.3-py3-none-any.whl.

File metadata

  • Download URL: dmdm-2.0.3-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.10.6 Linux/5.15.0-1031-azure

File hashes

Hashes for dmdm-2.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c8efa86d7a6c11d997d38167e0af2ad4082796b0971b5adf0d03eddc888473a3
MD5 73efc3b82432ed593ba5b463803c8053
BLAKE2b-256 25a7c7b44c3268ed71e96fa74b55e4217b2358d4c08165cf38573b8391484050

See more details on using hashes here.

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