'SRE Mail' is a Python package designed to make sending email in MIME format a lot easier.
from datetime import datetime
from sremail import message, smtp
msg = message.Message(to=["Sam Gibson <[email protected]>", "[email protected]"],
from_addresses=["[email protected]"],
date=datetime.now(),
another_header="test")
.attach("attachment.pdf")
smtp.send(msg, "smtp.some_server.com:25")
- You can't add the
X-FileTrust-Tenant
header to aMessage
with a kwarg, as there's no way to format it in a general way due to the capitalised 'T' in 'Trust'. To get around this you have to add the header manually:msg = message.Message(to=["Sam Gibson <[email protected]>", "[email protected]"], from_addresses=["[email protected]"], date=datetime.now()) msg.headers["X-FileTrust-Tenant"] = "<guid>"
- Python 3.6+
- Pipenv
- Clone this repo.
- Run
pipenv sync --dev
. - You're good to go. You can run commands using the package inside a
pipenv shell
, and modify the code with your IDE.