Django Saas Email Manager
An email manager for sending emails with templates, mail history and admin.
Features
Use of Mailhog for local email testing.
Send emails via django-anymail (using Sendgrid as default).
Serving dynamic HTML E-Mail Templates, editable with Tinymce.
Use of the awesome Transactional email templates from Mailgun.
Documentation
The full documentation is at https://django-saas-email.readthedocs.io.
Quickstart
Installation
Installation with pip:
pip install django-saas-email
Add it to your INSTALLED_APPS:
INSTALLED_APPS = (
...
'django_saas_email.apps.DjangoSaasEmailConfig',
...
)
Add a template engine TEMPLATES:
TEMPLATES = [
...
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"APP_DIRS": True,
"DIRS": ["django_saas_email/templates/"],
"NAME": "email",
"OPTIONS": {"string_if_invalid": "{%s}"},
}
]
JSONField
We are using the Postgres JSONField as default. If you installed psycopg2, everything should work fine.
If you are using a different database, you also need to install jsonfield:
pip install jsonfield
Adding the Sendgrid API Key to your settings
In settings.py:
SENDGRID_API_KEY=<....>
Other optional settings:
DJANGO_SAAS_TEST_EMAIL_ADDRESS=youremailfortesting@example.org DJANGO_SAAS_FOOTER="""Follow <a href="#" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 12px; color: #999; text-decoration: underline; margin: 0;">@yourcompany</a> on Twitter"""
Sending emails
from django_saas_email.utils import create_and_send_mail
context={
'first_name': 'John',
'last_name': 'Doe',
}
create_and_send_mail(
template_name="hello_world",
context=context,
to_address="john.doe@example.org"
)
This will create an email and send it with Sengrid.
You should use http://premailer.dialect.ca or django-premailer to create Inline CSS in HTML
Background sending
This module sends emails asynchronously. To do that, it uses celery. You will need to run and configure celery to really send emails using the library.
The best source to do that is First Steps with Celery.
But you may use the following simple guide if you want to make it fast:
Create a celery.py file aside your wsgi.py file with the following content:
from __future__ import absolute_import, unicode_literals
import os
from celery import Celery
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
app = Celery(<YOUR_APP_NAME>)
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()
Change <YOUR_APP_NAME> to the name of your app.
Install RabbitMQ.
Run celery:
celery -A <YOUR_APP_NAME> worker -B -l debug
Change <YOUR_APP_NAME> to the name of your app.
Now you might just send the email with no problem using create_and_send_mail function.
Running Tests
Does the code actually work?:
source <YOURVIRTUALENV>/bin/activate (myenv) $ pip install tox (myenv) $ tox
History
0.1.0 (2017-07-24)
First release on PyPI.
Metadata
Release files for django-saas-email 0.1.30
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django-saas-email-0.1.30.linux-x86_64.tar.gz | 27.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_saas_email-0.1.30-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 48.4 kB
Release files / django-saas-email-0.1.30.linux-x86_64.tar.gz
| Download URL | django-saas-email-0.1.30.linux-x86_64.tar.gz |
|---|---|
| Size | 27.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e2f90dd1febad0745d4c8a904837a63cca550686c44d9a28f1238edbae5cf011
|
|
BLAKE2b-256 checksum How to use checksums |
daa1d698e09d9b551cb8a25b03605a9688cf811d01b24d881fd53f1266245ca2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
|
Release files / django_saas_email-0.1.30-py2.py3-none-any.whl
| Download URL | django_saas_email-0.1.30-py2.py3-none-any.whl |
|---|---|
| Size | 20.7 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
f5cf45645aa21694f29ee91c9aff16c962b868e9b2ea67cc18f201db689f38c5
|
|
BLAKE2b-256 checksum How to use checksums |
f1924339162966049b18c08bf15cc5510184117e7dbaeacca0d048ee625fd2d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
|