This is a small tool to send personalized emails based on a recipients.json
file and a markdown template, providing some metadata in a yaml
header.
Use
pip install https://github.com/pep-dortmund/personalized-emails/archive/v0.1.0.tar.gz
To send the mails, do
jinjamails /path/to/template.md /path/to/recipients.json [options]
Recipients are currently read from a json
file like this:
[
{"firstname": "John", "lastname": "Doe", "email": "[email protected]"},
{"firstname": "Jane", "lastname": "Doe", "email": "[email protected]"}
]
These are the required fields to send an email. You can add more, which you can then use in the templates.
We plan to support more database / file types.
This tool uses markdown
with the jinja2
templating language.
One record of the recipient database is passed to the template as recipient
.
To access an element, you can use:
{{ recipient.firstname }}
For more possibilities, have a look into the jinja2
docs.
Metadata is given in a yaml
header on top of the template:
---
subject: My first try with personalized email
author: me
author_email: [email protected]
---
You also have access to the metadate in the templates, e.g. using
Cheers
{{ metadata.author }}
Use the attachments
meta tag to add attachments:
---
subject: My first try with personalized email
author: me
author_email: [email protected]
attachments:
- /path/to/attachment
---
We currently support two backends:
- smtp via the python standard library modules
smtplib
andemail
- mailgun via
requests
The tool will look for a config.cfg or
you set the path of the configfile using the -c /path/to/config/file
option.
If no backend is specified via the -b
command line option,
the first backend found in the config file is used.
If you want to use smtplib
, put this into your config file:
[smtplib]
host: ...
port: ...
user: ...
You can also provide a password
, if not, you will be asked for it.
If you want to use mailgun
, put this into your config file:
[mailgun]
domain: ...
authkey: ...