Send templated emails in markdown
Project description
MarkdownMerge
#hide
from markdown_merge.markdown_merge import *
Install
pip install markdown_merge
How to use
Provide your SMTP server settings, e.g. for AWS SES
import os
servernm = 'email-smtp.us-west-2.amazonaws.com'
username = os.getenv('SES_SMTP_USER')
password = os.getenv('SES_SMTP_PASS')
smtp_cfg = dict(host=servernm, port=587, user=username, password=password, use_ssl=False, use_tls=True)
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
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, smtp_cfg=smtp_cfg, inserts=inserts, test=True)
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.*
========================================
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
markdown_merge-0.1.0.tar.gz
(9.5 kB
view details)
File details
Details for the file markdown_merge-0.1.0.tar.gz.
File metadata
- Download URL: markdown_merge-0.1.0.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
073d3a67d9deae46e0869ead2ebac31fba303ed2f936689aa305296f68a1b019
|
|
| MD5 |
6aff11cc238c0974c9d5150ddb904fbd
|
|
| BLAKE2b-256 |
03c44b3c16d0fdef3f6751531af0dd6cb66a91e657916ea3bacfe19e334e3d3e
|