MailToolsBox is a comprehensive Python library designed to simplify email handling, making it easy to send, manage, and automate email workflows. Whether you need to send emails with attachments, use HTML templates, or securely authenticate with SMTP, MailToolsBox is the perfect solution.
š Key Features
ā EmailSender Class (New & Improved)
- Send emails via SMTPĀ with support forĀ CC, BCC, and multiple recipients.
- TLS/SSL encryptionĀ forĀ secureĀ email transmission.
- HTML & Plain Text SupportĀ for rich email formatting.
- Attachment HandlingĀ to send multiple files effortlessly.
- Jinja2 Template SupportĀ forĀ dynamic, personalized emails.
š Template-Based Emails with Jinja2
- Create and sendĀ HTML emails using templates.
- Autoescapes content forĀ safe rendering.
- Makes emailsĀ more dynamic and customizable.
š Secure & Reliable
- UsesĀ email-validatorĀ to ensureĀ valid recipient emails.
- SupportsĀ TLS encryptionĀ for better security.
- Built-in error loggingĀ to handle SMTP issues.
š Backward Compatibility with SendAgent
- OlderĀ
SendAgent
Ā implementationsĀ still work. - EncouragesĀ migration toĀ
EmailSender
Ā for better performance.
š„ Installation
You can install or upgrade MailToolsBox via PyPI:
pip install --upgrade MailToolsBox
š Quick Start – Sending an Email
With MailToolsBox, sending emails is incredibly easy.
from MailToolsBox import EmailSender
# Email configuration
sender = EmailSender(
user_email="your@email.com",
server_smtp_address="smtp.example.com",
user_email_password="yourpassword",
port=587
)
# Send an email
sender.send(
recipients=["recipient@example.com"],
subject="Hello from MailToolsBox",
message_body="This is a test email."
)
š Sending an HTML Email with Attachments
sender.send(
recipients=["recipient@example.com"],
subject="HTML Email Example",
message_body="""<h1>Welcome!</h1><p>This is an <strong>HTML email</strong>.</p>""",
html=True,
attachments=["/path/to/document.pdf"]
)
š Using Email Templates (Jinja2 Support)
MailToolsBox now supports Jinja2 templates for clean and structured emails.
Example Template (templates/welcome.html
):
<html>
<head>
<title>Welcome</title>
</head>
<body>
<h1>Welcome, {{ username }}!</h1>
<p>Click <a href="{{ activation_link }}">here</a> to activate your account.</p>
</body>
</html>
Sending a Templated Email:
context = {
"username": "John Doe",
"activation_link": "https://example.com/activate"
}
sender.send_template(
recipient="recipient@example.com",
subject="Welcome to Our Service",
template_name="welcome.html",
context=context
)
š Why Choose MailToolsBox?
ā Simple & Clean API – Designed for developers.
ā Security First – TLS/SSL encryption for safe email sending.
ā High Performance – Optimized for large email batches.
ā Easy to Integrate – Works with any Python project.
š SEO Focus Keywords & Tags
Tags: Python, Email Automation, SMTP, Email API, Email Tools, Python Email Library, EmailSender, MailToolsBox
Focus Keywords: Python email library, MailToolsBox, SMTP email sending, Python email automation, secure email library
š Download & Resources
š Official Documentation: rambod.net
š¦ PyPI Package: MailToolsBox on PyPI
š GitHub Repository: MailToolsBox on GitHub
š¤ Contribution & Community
We welcome contributions! If you’d like to improve MailToolsBox:
- Fork the repository on GitHub.
- Create a new feature branch.
- Implement changes and write tests.
- Submit aĀ pull requestĀ for review.
Let’s make MailToolsBox the best Python email automation library together! š