MailToolsBox is a comprehensive Python library that simplifies email server interaction for developers. Whether you need to send complex emails with attachments or retrieve and manage emails via IMAP, MailToolsBox is the go-to solution. It offers two powerful classes: SendAgent for sending emails and ImapAgent for receiving emails.
Key Features
- SendAgent Class:
- Send emails via SMTP with support for CC, BCC, and attachments.
- TLS support for secure email transmission.
- Easy-to-use
send_mail()
method that integrates seamlessly with your Python applications. - Example use case for sending emails with just a few lines of code.
- ImapAgent Class:
- Retrieve emails from an IMAP server efficiently.
- Download emails in various formats (plain text, JSON,
.msg
). - Provides methods such as
login_account()
anddownload_mail_text()
to streamline email management.
Installation
Install MailToolsBox via PyPI:
pip install MailToolsBox
Quick Start Example
Here’s how you can quickly send an email using the SendAgent class:
from MailToolsBox import SendAgent
user_email = "example@gmail.com"
user_email_password = "password"
server_smtp_address = "smtp.gmail.com"
port = 587
send_agent = SendAgent(user_email, server_smtp_address, user_email_password, port)
recipient_email = "recipient@example.com"
subject = "Test email"
message_body = "This is a test email sent using MailToolsBox."
send_agent.send_mail(recipient_email, subject, message_body)
In this example, MailToolsBox allows you to easily integrate email functionality into your Python applications with minimal effort.
ImapAgent Example
For receiving emails, use the ImapAgent class:
from MailToolsBox import ImapAgent
email_account = 'your_email@example.com'
password = 'your_password'
server_address = 'imap.example.com'
imap_agent = ImapAgent(email_account, password, server_address)
imap_agent.download_mail_text()
With MailToolsBox, you can retrieve and process emails with the same ease as sending them.
Download & Resources
You can download and explore MailToolsBox directly from PyPI.
- Homepage: MailToolsBox Project Page
- License: MIT License
Contribution & Community
Pull requests are welcome! For major changes, please open an issue first to discuss the proposed changes. When contributing, ensure that all new features and changes are well-tested and documented.
SEO Focus Keywords & Tags:
- Tags: Python, Email Automation, SMTP, IMAP, Email Tools
- Focus Keywords: Python email library, MailToolsBox, SendAgent, ImapAgent, email server tools