django-epfl-mail
A Django application with templates for emails.
Requirements
- Python 3.6 or later
- Django 2.2 or 3.2
Installation
Installing from PyPI is as easy as doing:
pip install django-epfl-mail
Documentation
Setup
Add 'django_epflmail'
to your INSTALLED_APPS
setting.
INSTALLED_APPS = [
...
'django_epflmail',
]
Example template
from django.core.mail.message import EmailMessage
from django.template.loader import render_to_string
html = render_to_string("example.html", {"APP_TITLE": "Example"})
email = EmailMessage(
"Email Example", html, "from@example.com", ["to@example.com"]
)
email.send()
{% extends "epflmail/default.html" %}
{% load i18n %}
{% block title %}
Email Example
{% endblock %}
{% block online %}
{% with ONLINE_VERSION_LINK="https://example.com" %}
{% include 'epflmail/includes/online.inc.html'%}
{% endwith %}
{% endblock %}
{% block main %}
<p>This is an example.</p>
{% endblock %}
{% block unsubscribe %}
<a href="https://example.com">Unsubscribe link</a>
{% endblock %}