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
Built Distribution
Hashes for fluentcms-emailtemplates-0.2.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1c18eb58641bf59124e501428d330a8609d2d6b37a81822b34fade0aa65f525 |
|
MD5 | b3d96d43db0d77092979ba86be6da391 |
|
BLAKE2b-256 | da0c9745bfd3ba88686e4e39f38a1eff124b4e868ee9fa1e6e53d53302763075 |
Hashes for fluentcms_emailtemplates-0.2.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad5bf2c589171b87abceb1b70e7b3482c24fb990360d6112e566574bfc07e5c9 |
|
MD5 | aeda5a4ce11a7f91bf518255a80d9f7a |
|
BLAKE2b-256 | 8fd5e271e4c29e81dfdfc1079f22b3cee589b07207c5e8f37b7e6f3bebc53e09 |