Skip to main content

An extension for django-templated-email for creating emails with Markdown

Reason this release was yanked:

Missing files

Project description

django-templated-email-md

PyPI Status Python Version License

Read the documentation at https://django-templated-email-md.readthedocs.io/ Tests Codecov

pre-commit Black

Features

  • Markdown Templates: Write email templates using Markdown syntax for cleaner and more readable templates.
  • Automatic Conversion: Automatically converts Markdown to HTML and generates a plain text version of emails.
  • CSS Inlining: Inlines CSS styles for better email client compatibility using Premailer.
  • Seamless Integration: Works as an extension of django-templated-email, allowing for easy integration into existing projects.
  • Template Inheritance: Supports Django template inheritance and template tags in your Markdown templates.

Installation

You can install django-templated-email-md via pip from PyPI:

pip install django-templated-email-md

Add to INSTALLED_APPS

Add templated_email_md to your INSTALLED_APPS in settings.py:

INSTALLED_APPS = [
    # ...
    'templated_email_md',
    # ...
]

Configuration

Assuming you have already installed and configured django-templated-email, update your Django settings as follows:

# settings.py

# Configure the templated email backend
TEMPLATED_EMAIL_BACKEND = 'templated_email_md.backend.MarkdownTemplateBackend'

# Optional: Specify the base HTML template for wrapping your content. See the Usage guide for details.
TEMPLATED_EMAIL_BASE_HTML_TEMPLATE = 'templated_email/markdown_base.html'

# Set the directory where your email templates are stored
TEMPLATED_EMAIL_TEMPLATE_DIR = 'templated_email/'  # Ensure there's a trailing slash

# Define the file extension for your Markdown templates
TEMPLATED_EMAIL_FILE_EXTENSION = 'md'

# Optional: Specify Markdown extensions if needed
TEMPLATED_EMAIL_MARKDOWN_EXTENSIONS = [
    'markdown.extensions.extra',
    'markdown.extensions.meta',
    'markdown.extensions.tables',
]

Usage

Creating Markdown Templates

Place your Markdown email templates in the templated_email/ directory within your project's templates directory. For example, create a file templated_email/welcome.md:

{% block subject %}Welcome to Our Service{% endblock %}

{% block preheader %}Thanks for signing up!{% endblock %}

{% block content %}
# Welcome, {{ user.first_name }}!

We're thrilled to have you join our service. Here are a few things you can do to get started:

1. **Complete your profile**
2. **Explore our features**
3. **Connect with other users**

If you have any questions, don't hesitate to reach out to our support team.

Best regards,
The Team
{% endblock %}

Sending Emails

Use the send_templated_mail function to send emails using your Markdown templates, just as you would with the base django-templated-email package:

from templated_email import send_templated_mail

send_templated_mail(
    template_name='welcome',
    from_email='from@example.com',
    recipient_list=['to@example.com'],
    context={
        'user': user_instance,
        # Add other context variables as needed
    },
)

More detailed information can be found in the usage guide.

Documentation

For more detailed information, please refer to the full documentation.

Contributing

Contributions are very welcome. To learn more, see the Contributor Guide.

License

Distributed under the terms of the MIT license, django-templated-email-md is free and open source software.

Issues

If you encounter any problems, please file an issue along with a detailed description.

Credits

We are grateful to the maintainers of the following projects:

This project was generated from @OmenApps's Cookiecutter Django Package template.

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_templated_email_md-2024.10.2.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file django_templated_email_md-2024.10.2.tar.gz.

File metadata

File hashes

Hashes for django_templated_email_md-2024.10.2.tar.gz
Algorithm Hash digest
SHA256 116e0103ea937797a1573ebfaf41abbd5bab1b250a551b411eb096935568afed
MD5 5a479e9e1da7c5585c84d3d9694c3069
BLAKE2b-256 6cd670284da24e8cb4c2eddf95d2ae6e89befc7806eee6d88c095f47716c5b71

See more details on using hashes here.

File details

Details for the file django_templated_email_md-2024.10.2-py3-none-any.whl.

File metadata

File hashes

Hashes for django_templated_email_md-2024.10.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5ce4c58ef1837a33bd378a8162fb1b2e349bb6b9a322a2c70d421146c7efc5cd
MD5 076b506550ebedde0a8be48b41b1d370
BLAKE2b-256 e9bb3b1a1d7b411bd79d3eb770146a68de70980a4fd5acaf7b27aeec4b67b60e

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