MailToolsBox 1.0.0 – Major Release with Enhanced Features 🚀

We are thrilled to announce the release of MailToolsBox 1.0.0, a major update that brings enhanced email handling, improved security, better error management, and much more!

🎉 What’s New in MailToolsBox 1.0.0?

This version is a complete revamp of the library, making it more efficient, secure, and developer-friendly. Below are the key updates:

1. Redesigned EmailSender Class

  • Provides a modern, easy-to-use API for sending emails.
  • Supports plain text & HTML emails.
  • Works with multiple recipients (To, CC, BCC).
  • TLS/SSL security enhancements.

📂 2. Attachment Handling

  • Easily attach multiple files to your emails.
  • Ensures files exist before sending.
  • Provides error logging for missing attachments.

🏗 3. Jinja2-Based Email Templates

  • Now supports HTML email templates with variables.
  • Uses Jinja2 for dynamic email rendering.
  • Simplifies templated email handling.

🛡 4. Improved Security & Email Validation

  • Uses email-validator to ensure valid email addresses.
  • Supports secure authentication with TLS/SSL.
  • Encourages best practices for email security.

🔧 5. Better Error Handling & Logging

  • Uses Python’s logging module to track issues.
  • Provides clear error messages.
  • Gracefully handles SMTP errors.

🔄 6. Backward Compatibility with SendAgent

  • Maintains support for older code using SendAgent.
  • Displays warnings to encourage migration.

📥 Installation

You can install or upgrade to the latest version of MailToolsBox using pip:

pip install --upgrade MailToolsBox

🚀 How to Use MailToolsBox 1.0.0

1. Sending a Basic Email

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
)

# Sending email
sender.send(
    recipients=["recipient@example.com"],
    subject="Test Email",
    message_body="Hello, this is a test email!"
)

2. 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"]
)

3. Using Jinja2 Templates for Emails

MailToolsBox now supports Jinja2 templates for easy email customization.

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 an Email with a Template:

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
)

4. Sending Emails with CC & BCC

sender.send(
    recipients=["recipient@example.com"],
    subject="CC & BCC Example",
    message_body="This email has CC and BCC recipients!",
    cc=["cc@example.com"],
    bcc=["bcc@example.com"]
)

5. Backward Compatibility with SendAgent

For users migrating from older versions, SendAgent still works:

from MailToolsBox import SendAgent

legacy_sender = SendAgent(
    user_email="your@email.com",
    server_smtp_address="smtp.example.com",
    user_email_password="yourpassword",
    port=587
)

legacy_sender.send_mail(
    recipient_email=["recipient@example.com"],
    subject="Legacy Compatibility Test",
    message_body="Testing backward compatibility."
)

🔐 Best Practices for Security

  • Use environment variables instead of hardcoding credentials.
  • Enable 2FA on your email provider and use app passwords if required.
  • Use TLS/SSL to secure email communication.

Example using environment variables:

import os

sender = EmailSender(
    user_email=os.getenv("EMAIL"),
    server_smtp_address=os.getenv("SMTP_SERVER"),
    user_email_password=os.getenv("EMAIL_PASSWORD"),
    port=int(os.getenv("SMTP_PORT", 587))
)

🔥 Conclusion

The 1.0.0 release of MailToolsBox is a significant upgrade, making email handling more secure, efficient, and flexible. With modern API improvements, enhanced logging, better security, and backward compatibility, it’s the best version yet!

🌍 Learn More & Stay Updated

🔹 If you have any questions, feel free to contribute, report issues, or suggest improvements! 🚀


🛠 How to Contribute

MailToolsBox is an open-source project. Contributions are always welcome!

  1. Fork the repository on GitHub.
  2. Create a new feature branch.
  3. Implement changes and write tests.
  4. Submit a pull request.

Thank you for your support! 🎉

📢 Don’t forget to update to MailToolsBox 1.0.0 today!

Recommended Posts

No comment yet, add your voice below!


Add a Comment

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

20 − 6 =