Skip to main content

Creating e-mail messages, with multiple layouts and multilingual content.

Project description

fluentcms-emailtemplates

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',
)

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 = None

# 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()

Contributing

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

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

fluentcms-emailtemplates-0.1.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

fluentcms_emailtemplates-0.1-py2.py3-none-any.whl (23.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file fluentcms-emailtemplates-0.1.tar.gz.

File metadata

File hashes

Hashes for fluentcms-emailtemplates-0.1.tar.gz
Algorithm Hash digest
SHA256 e7b22168bfa20f74d4408ec745c1d5a9534c27c8017d71f8f237d71f327c7df0
MD5 1c871b98be63b2c90085cb7b2c6de8a4
BLAKE2b-256 09793bb987ab1161a0f3f671b435c0ea6e7a3746686625f52e3c0f98bd91f065

See more details on using hashes here.

File details

Details for the file fluentcms_emailtemplates-0.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for fluentcms_emailtemplates-0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 55123c9e857299d410e5434f0dc7ef6237f9de4c83ab1d813e8af984f0b876d5
MD5 bad94735dc0aad771f8dcae788499725
BLAKE2b-256 b1e53877578c4519893110b0b7e206d81eab23a9b0a6dc8e9f0ec039ac520b4f

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