Flask-Mailman-Templates
Templates for Flask-Mailman
- Define your emails as templates
- Optionnaly use a yaml frontmatter to define metadata like subject
- Support for markdown emails
- Support for MJML
- Inline css using premailer
- Optionnaly auto generate text alternative from html emails (if html2text is installed)
Installation
pip install flask-mailman-templates
Usage
Initialize Flask-Mailman first then Flask-Mailman-Templates:
from flask import Flask
from flask_mailman import Mail
from flask_mailman_templates import MailTemplates
app = Flask(__name__)
mail = Mail(app)
mail_templates = MailTemplates(app)
Create templates in an email folder. Example email/hello.txt:
---
subject: Hello world
---
Hello from Flask!
Send your email using either TemplatedEmailMessage or send_mail():
from flask_mailman_templates import TemplatedEmailMessage, send_mail
msg = TemplatedEmailMessage("hello.txt", "hello@example.com")
msg.send()
# or
send_mail("hello.txt", "hello@example.com")
The frontmatter is optionnal and options can be passed as keyword arguments (keyword args override the frontmatter if both are used)
send_mail("hello.txt", "hello@example.com", subject="hello world")
Supported formats
| Format | File extension | Required dependency | Description |
|---|---|---|---|
| txt | txt | Text email only | |
| HTML | html | HTML email only | |
| Markdown | md | markdown | Text + HTML email |
| MJML | mjml | mjml | HTML email only |
If html2text is installed, HTML emails will be automatically converted to text and both content types will be attached (does not apply to markdown).
Configuration
| Config key | Extension argument | Description | Default |
|---|---|---|---|
| MAIL_TEMPLATES_FOLDER | template_folder | Location of email templates | emails |
| MAIL_TEMPLATES_MARKDOWN_OPTIONS | markdown_options | Options for the markdown function | {} |
| MAIL_TEMPLATES_INLINE_CSS | inline_css | Whether to inline css with premailer if installed | True |
| MAIL_TEMPLATES_AUTO_TEXT_BODY_FROM_HTML | auto_text_body_from_html | Whether to convert HTML content to text content if html2text is installed | True |
Metadata
Release files for flask-mailman-templates 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| flask_mailman_templates-0.1.2.tar.gz | 3.8 kB | Without provenance | Details for flask_mailman_templates-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flask_mailman_templates-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for flask_mailman_templates-0.1.2-py3-none-any.whl |
Total release size: 8.2 kB
Release files / flask_mailman_templates-0.1.2.tar.gz
| Download URL | flask_mailman_templates-0.1.2.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
44f898d88e501373f750710634091c3a15f8d72cc41e6bcc5169f2338c0866aa
|
|
BLAKE2b-256 checksum How to use checksums |
ba200ac560c33b07bc6c41e88fb5585d70373bb5f8fcf075812ebc0779f55b8a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.10.12 Linux/6.8.0-40-generic
|
Release files / flask_mailman_templates-0.1.2-py3-none-any.whl
| Download URL | flask_mailman_templates-0.1.2-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a8709b521ce3904f5e117751bca60674dcef0defad51db89a732892f6fabc85e
|
|
BLAKE2b-256 checksum How to use checksums |
89e9b5f320b2055d6e94d52f9be623096206933020d2a679206bd9e4d79e4e81
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.10.12 Linux/6.8.0-40-generic
|
Security for flask-mailman-templates 0.1.2
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.