Htmessage is simple extension of django's official EmailMessage. It is adapted to work with django templating engine or any templating engine adapted to work with django.
Project description
#Docs for Htmailer.
Htmessage is simple extension of django's official EmailMessage. It is adapted to work with django templating engine or any templating engine adapted to work with django.
Htmessage subclasses Django.core.mail.EmailMessage
User defines instance of Htmailer like so
from htmailer import Htmessage
`message = Htmessage()`
`message.subject('subject goes here')`
`message.html_template('mail_html.html', context)`
`message.txt_template('mail_text.html', context)`
'mail_*.html' is a path to the template where the mail is defined.
This works like standard django Render() function, such that 'mail_*.html' is searched for in the dirs
defined in the TEMPLATE setting Dictconfig.
Since this mailer extends EmailMessage, standard behaviour like send(), header() are available,
that the content of rendered text template from the mailer is the body of the text message and manually setting body()
will replace the rendered text but will have no effect on the html part of the message.
#USAGE
class Htmessage
- constructed like
Django.core.mail.EmailMessagehtml_template(template, context) templateis a path to the html file containing the template.contextis a dictionary containing context data to replace the place holders in the html file.txt_template(template, context)works just likehtml_template()above.
The html file for txt template should not contain html document, its content should just be text with with placeholders according to the style of the Template Engine used by your project
For example, the html file can contain;
<html>
<head>
<title>Welcome to htmailer</title>
</head>
<body>
Dear {{user_name}},<br>
welcome to htmailer, I hope you wil find it useful one way or another.
signed,
{{company_name}}
</body>
</html>
and the text file can contain the same information but as plain text like so;
Dear {{user_name}},
welcome to htmailer, I hope you wil find it useful one way or another.
signed,
{{company_name}}.
This context for the html message above will be a dict like:
{'user_name': 'dino', 'company_name': 'A cute company'}
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file htmailer-1.0.1.tar.gz.
File metadata
- Download URL: htmailer-1.0.1.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
293f9ccea4fbb00c91e046df8f81d42f153bc906b8faf51f8cd266b3a53f6e81
|
|
| MD5 |
2a107df51eb6a6e64569f93d7621c466
|
|
| BLAKE2b-256 |
d68eb92b4cc8b492b2254c7f5441c8cb7ba26efaddf2e9c5cb03fb4750da07c2
|
File details
Details for the file htmailer-1.0.1-py3-none-any.whl.
File metadata
- Download URL: htmailer-1.0.1-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0736557472556f358a513927b5ab4830a625ff5221b81a5bcfcd059371ce28c
|
|
| MD5 |
018b17dd0731a2a3534c48e7fbe17ce7
|
|
| BLAKE2b-256 |
44ad8a8ba59fcaf6ee033530ddeecc7013629139813fec849832d81f450812c8
|