Skip to main content

fluentcms-emailtemplates

https://img.shields.io/travis/django-fluent/fluentcms-emailtemplates/master.svg?branch=master https://img.shields.io/pypi/v/fluentcms-emailtemplates.svg https://img.shields.io/badge/wheel-yes-green.svg https://img.shields.io/pypi/l/fluentcms-emailtemplates.svg https://img.shields.io/codecov/c/github/django-fluent/fluentcms-emailtemplates/master.svg

An email template system, that uses django-fluent-contents blocks to define the e-mail templates.

Features:

  • Multilingual content.

  • Multisite support.

  • Custom layouts (=Django templates).

  • Custom context variables

Installation

First install the module, preferably in a virtual environment. It can be installed from PyPI:

pip install fluentcms-emailtemplates

First make sure the project is configured for django-fluent-contents.

Then add the following settings:

INSTALLED_APPS += (
    'fluentcms_emailtemplates',
    'fluentcms_emailtemplates.plugins.emailtext',
)

FLUENTCMS_EMAILTEMPLATES_PLUGINS = (
    'EmailTextPlugin',
)

The database tables can be created afterwards:

./manage.py migrate

Configuration

The following settings are defined by default:

FLUENTCMS_EMAILTEMPLATES_LAYOUTS = (
    # A layout points to a template named:
    # fluentcms_emailtemplates/emails/{slug}/{layout}.html
    # fluentcms_emailtemplates/emails/{layout}.html
    ('default', _("Default")),
)

# Possible plugins to use in the email template.
# By default, that is FLUENT_CONTENTS_PLACEHOLDER_CONFIG['email_templates']
FLUENTCMS_EMAILTEMPLATES_PLUGINS = (
    'EmailTextPlugin',
)

# Add extras context data for an e-mail preview.
FLUENTCMS_EMAILTEMPLATES_PREVIEW_CONTEXT = {}

# Optionally allow developers to share email templates between all sites in a multisite setup.
FLUENTCMS_EMAILTEMPLATES_ENABLE_CROSS_SITE = False

# Enable multisite support by default
FLUENTCMS_EMAILTEMPLATES_FILTER_SITE_ID = True

Usage

Create email templates in the admin. Use the following code to create an email:

from email.utils import formataddr
from fluentcms_emailtemplates.models import *

template = EmailTemplate.objects.get_for_slug('order-confirmation')
email = template.get_email_message(
    base_url='http://example.org/',
    context={
        'order_number': "123-xy"
    },
    to=[
        formataddr(('You', 'you@example.org')),
    ],
)

email.send()

Tip: when creating a separate template for the plain-text email, start the template with {% autoescape off %}. This avoids creating HTML entities inside the plain-text email.

Contributing

If you like this module, forked it, or would like to improve it, please let us know! Pull requests are welcome too. :-)

Metadata

Release files for fluentcms-emailtemplates 2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fluentcms-emailtemplates 2.0
File Size Uploaded Provenance
fluentcms-emailtemplates-2.0.tar.gz 27.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for fluentcms-emailtemplates 2.0
File Interpreter ABI Platform
fluentcms_emailtemplates-2.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 64.4 kB

Release files / fluentcms-emailtemplates-2.0.tar.gz

Download URL fluentcms-emailtemplates-2.0.tar.gz
Size 27.2 kB
Tags Source
SHA-256 checksum
How to use checksums
635fe64ca87aa7fd61a93766cc555901e6ce06a3f66dc76a66511c2a9095549d
BLAKE2b-256 checksum
How to use checksums
8f65224bdb72db8dc540dab202185f5a67a8c243ff21f60c942f7880ee996401
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / fluentcms_emailtemplates-2.0-py2.py3-none-any.whl

Download URL fluentcms_emailtemplates-2.0-py2.py3-none-any.whl
Size 37.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
eda770cdd48178fe08d6c9d4894b1db62c2abc128455e9d6809c2390d22580d5
BLAKE2b-256 checksum
How to use checksums
3318faee5841508c80eea87f6a31836cff6db4fd7fae03bf4828122e3640a47a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for fluentcms-emailtemplates 2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page