This is a sister library for Red Box, advanced email reader.
Red Mail is a Python library for sending emails. It makes sending emails very trivial regardless of whether you need to embed images, plots, tables or attach documents. It also provides you convenient templating options and it is easy to create email alerts, email reports or client notifications with it.
Visit the source code from Github or releases in Pypi page.
Why Red Mail?¶
Sending emails is a pretty straight forward task. However, the SMTP and email libraries from the standard library don’t make it particularly easy.
Sending emails SHOULD NOT look like this:
import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText msg = MIMEMultipart('alternative') msg['Subject'] = 'An example email' msg['From'] = 'firstname.lastname@example.org' msg['To'] = 'email@example.com' part1 = MIMEText("Hello!", 'plain') part2 = MIMEText("<h1>Hello!</h1>", 'html') msg.attach(part1) msg.attach(part2) # Send the message via our own SMTP server. s = smtplib.SMTP('localhost', port=0) s.send_message(msg) s.quit()
It should look like this:
from redmail import EmailSender email = EmailSender(host="localhost", port=0) email.send( subject="An example email", sender="firstname.lastname@example.org", receivers=['email@example.com'], text="Hello!", html="<h1>Hello!</h1>" )
There are also other reasons to use Red Mail:
And it is well tested and documented
Interested in more? Here are some more quick examples:
Install the package:
pip install redmail
Some more practical examples:
- Frequently Asked Questions
- Version history