Send templated emails in markdown.
pip install markdown_merge
cfg = dict(EMAIL_HOST='smtp.fastmail.com', EMAIL_PORT=465,
EMAIL_HOST_USER='XXX@fastmail.com', EMAIL_HOST_PASSWORD='XXX', EMAIL_USE_SSL=True)
Alternately you can put your server settings in mail_settings.py
. There's an example settings file in the repo.
from_addr = get_addr('XXX@fastmail.com', 'Jeremy Howard')
to_addrs = [get_addr('douglas@example.com', 'Douglas Adams'),
get_addr('cleese@example.com', 'John Cleese')]
inserts = [{'special': "Thanks for all the fish."},
{'special': "That was a silly walk."}]
msg = """## Hello there!
Here is your special message: *{special}*"""
ml = MarkdownMerge(to_addrs, from_addr, 'A message', msg=msg, inserts=inserts)
Optionally, enable test mode to just print the messages, instead of sending them.
ml.set_test(True)
ml.send_msgs()
All the hard work is done by Django mail, python-markdown, and python. So thanks to the authors of those projects!