#hide
from markdown_merge.markdown_merge import *
MarkdownMerge
Send templated emails in markdown.
Install
pip install markdown_merge
How to use
Provide your SMTP server settings, e.g. for AWS SES
import os
= 'email-smtp.us-west-2.amazonaws.com'
servernm = os.getenv('SES_SMTP_USER')
username = os.getenv('SES_SMTP_PASS')
password = dict(host=servernm, port=587, user=username, password=password, use_ssl=False, use_tls=True) smtp_cfg
You can configure your SMTP server settings using the smtp_cfg
dictionary format shown above. The example uses AWS SES with environment variables for credentials.
Provide your email details
= get_addr('XXX@fastmail.com', 'Jeremy Howard')
from_addr = [get_addr('douglas@example.com', 'Douglas Adams'),
to_addrs 'cleese@example.com', 'John Cleese')]
get_addr(= [{'special': "Thanks for all the fish."},
inserts 'special': "That was a silly walk."}]
{
= """## Hello there!
msg
Here is your special message: *{special}*"""
= MarkdownMerge(to_addrs, from_addr, 'A message', msg, smtp_cfg=smtp_cfg, inserts=inserts, test=True) ml
The test=True
parameter prints the messages instead of sending them.
Send your messages
ml.send_msgs()
To: Douglas Adams <douglas@example.com>
----------------------------------------
## Hello there!
Here is your special message: *Thanks for all the fish.*
========================================
To: John Cleese <cleese@example.com>
----------------------------------------
## Hello there!
Here is your special message: *That was a silly walk.*
========================================