Red Mail

raw JSON →
0.6.0 verified Fri May 01 auth: no python

Red Mail is a modern email sending library for Python that allows sending emails with attachments, embedded images, Jinja templating, and support for multiple email protocols (SMTP, Outlook, Gmail, etc.). The current version is 0.6.0, with an active release cadence. It requires Python >=3.6.

pip install redmail
error AttributeError: 'EmailSender' object has no attribute 'user_name'
cause The parameter `user_name` was renamed to `username` in v0.4.0.
fix
Use username='your@email.com' instead of user_name='...'.
error ModuleNotFoundError: No module named 'pandas'
cause Tried to use pandas-related features (like table prettifying) without having pandas installed.
fix
Install pandas with pip install pandas or install redmail with extras: pip install redmail[pandas].
error smtplib.SMTPAuthenticationError: (535, b'5.7.8 Username and Password not accepted')
cause Incorrect email credentials or less secure app access not enabled (for Gmail).
fix
Check username/password, enable less secure app access or use an app password.
gotcha The `user_name` parameter was renamed to `username` in v0.4.0. Using `user_name` will raise an error.
fix Use `username=...` instead of `user_name=...`.
deprecated The `password` parameter is still accepted but its use is deprecated; use `password` is fine, but consider using environment variables or a secrets manager.
fix No immediate change, but avoid hardcoding credentials.
gotcha When using `send` with `text` and `html` arguments, the email structure might be multipart/alternative. If you don't set a text body, some clients may not display HTML properly.
fix Always provide both `text` and `html` unless you intend plain text only.
gotcha Embedded images require a valid Content-ID; if the image is not embedded correctly, it may not display. Use `embed_image` parameter with image path or bytes.
fix Refer to docs: pass image as `attachments` with `content_id`.
pip install redmail[pandas]

Basic usage: create an EmailSender with SMTP credentials and send a simple email.

from redmail import EmailSender

email = EmailSender(
    host="smtp.example.com",
    port=587,
    username="user@example.com",
    password="secret",
    use_startls=True
)
email.send(
    subject="Example",
    receivers=["recipient@example.com"],
    text="Hello!",
    html="<h1>Hello!</h1>"
)