I’m excited to announce the release of MailToolsBox 1.1.0, a major update to my open‑source Python email library. This update turns MailToolsBox into a full‑stack email toolkit: secure SMTP sending (sync and async), Jinja2 templates, bulk sending, and now an upgraded IMAP client for receiving, searching, and managing mailboxes.

Whether you need to send transactional emails, build an async service, or automate mailbox ingestion, this version covers the full lifecycle.


🚀 What’s New in 1.1.0

1. SMTP Revamp

2. IMAP Client Upgrade

3. Developer Experience


🔧 Installation

Install from PyPI:

pip install MailToolsBox

📤 SMTP Usage Examples

Send a simple email

from MailToolsBox import EmailSender

sender = EmailSender.for_gmail_app_password("you@gmail.com", "abcd abcd abcd abcd")
sender.send(["to@example.com"], "Hello", "Plain text body")

Send HTML + attachments

html = "<h1>Report</h1><p>See attachment.</p>"
sender.send(
    recipients=["to@example.com"],
    subject="Monthly Report",
    message_body=html,
    html=True,
    attachments=["report.pdf", "chart.png"]
)

Use a Jinja2 template

sender.send_template(
    recipient="to@example.com",
    subject="Welcome",
    template_name="welcome.html",
    context={"user": "Alex", "link": "https://example.com/activate"}
)

Async sending

import asyncio

async def main():
    await sender.send_async(
        ["to@example.com"], "Async Email", "Sent without blocking!"
    )

asyncio.run(main())

📥 IMAP Usage Examples

Connect and fetch unseen emails

from MailToolsBox import ImapClient

with ImapClient.from_env() as imap:
    imap.select("INBOX")
    uids = imap.search("UNSEEN")
    for uid in uids:
        msg = imap.fetch(uid)
        print(msg.subject, msg.from_[0].email if msg.from_ else None)

Save attachments

attachments = imap.save_attachments(msg, "./attachments")

Export mailbox as JSON

imap.download_mail_json(lookup="UNSEEN", save=True, path="./dumps")

Save emails as .eml files

imap.download_mail_eml(directory="./eml", lookup="ALL")

🔒 Security Best Practices


📈 Why this matters

Most Python email libraries are either outdated (no async, no OAuth2), or too limited (send only). MailToolsBox now provides a full end‑to‑end solution: send, manage, and automate email workflows with modern security.

This makes it a great fit for:


📦 Next Steps

Future versions will focus on:


📜 Conclusion

MailToolsBox 1.1.0 is more than an update—it’s a transformation into a modern email framework for Python. It bridges the gap between sending and receiving with security, async support, and developer‑friendly features.

👉 Check it out on PyPI
👉 Source code on GitHub

Leave a Reply

Your email address will not be published. Required fields are marked *

7 − 3 =