YIYIMail 🚀
中文说明 | English Version
YIYIMail is a high-performance, modern Python library for email processing. It is designed to replace legacy libraries by providing seamless support for IMAP, POP3, and SMTP, featuring high-performance server-side search, elegant HTML/CID parsing, and extreme ease of use.
🌟 Key Features
- Modern Protocol Support: Full support for IMAP, POP3, and SMTP. Auto-identification for personal (Gmail, Outlook, 163, QQ) and Enterprise providers (Tencent, Ali, Netease).
- High-Performance Search: Leverage IMAP server-side search to locate emails instantly. Filter by Subject, Sender, Date, and Unseen status with limit support.
- Superior Compatibility: Built-in IMAP
IDcommand support to pass security checks of providers like 163.com and Tencent. - Smart Folder Matching: Automatically handles Modified UTF-7 encoding for non-ASCII folder names. Supports direct use of localized names like "已发送" or "Sent Messages".
- Elegant Parser: Automatically handles CID inline images and generates Base64-rendered HTML for perfect offline viewing.
- Utility Toolbox: Built-in
show()for pretty printing andsave()/load()for local persistence. - Type Safe: Fully typed with Python 3.7+ type hints.
📦 Installation
pip install YIYIMail
🚀 Quick Start
1. Connection
YIYIMail automatically identifies server settings based on your email domain.
import YIYIMail
# Use authorization codes for services like 163, QQ, etc.
mail = YIYIMail.connect('your_name@163.com', 'your_auth_code')
# Enterprise mail support (Auto-detects Tencent, Ali, Netease)
# mail = YIYIMail.connect('admin@exmail.qq.com', 'password')
# Or manual server configuration
# mail = YIYIMail.connect('user@company.com', 'pwd', smtp_host='smtp.company.com', imap_host='imap.company.com')
2. Send Emails
Supports multiple recipients, attachments, and HTML content.
mail.send(
recipients=['friend@example.com'],
subject='Hello',
content='This is a test email',
html='<h1>Hello</h1><p>Sent via YIYIMail!</p>',
attachments=['/path/to/report.pdf']
)
3. Advanced Search (IMAP)
Search on the server without downloading everything.
# Search for emails after May 1st, 2026, limit to 5 latest results
results = mail.search(after='2026-05-01', subject='Report', limit=5)
# Search for unseen emails from a specific sender
unread = mail.search(sender='boss@company.com', unseen=True)
# Search in a specific folder
sent = mail.search(subject='Project', folder='Sent Messages')
4. Fetch & Display
# Get the latest email
latest = mail.fetch_latest()
# Get a range of emails
mails = mail.fetch_mails(start=1, end=10)
# Pretty print content to console
YIYIMail.show(latest)
5. Status Management
uid = latest['uid']
mail.mark_as_read(uid) # Mark as seen
mail.mark_as_unread(uid) # Mark as unseen
6. Persistence
# Save to local JSON
YIYIMail.save(latest, 'my_mail.json')
# Load from local
local_mail = YIYIMail.load('my_mail.json')
7. Mailbox Information
# Get mailbox statistics (total count, size)
stats = mail.info()
print(f"Total Mails: {stats['count']}, Size: {stats['size_bytes']} bytes")
🛠️ Folder Management
Use mail.folders() to get decoded folder names from the server.
print(mail.folders())
# Output: ['INBOX', 'Drafts', 'Sent Messages', 'Trash', ...]
⚖️ License
MIT License
Metadata
Release files for YIYIMail 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| yiyimail-1.0.3.tar.gz | 11.1 kB | Without provenance | Details for yiyimail-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| yiyimail-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for yiyimail-1.0.3-py3-none-any.whl |
Total release size: 23.3 kB
Release files / yiyimail-1.0.3.tar.gz
| Download URL | yiyimail-1.0.3.tar.gz |
|---|---|
| Size | 11.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e8085de47046d4ef96f2254e0cb4bab4d87ee74421410aadd4eb008e1bd4486e
|
|
BLAKE2b-256 checksum How to use checksums |
b78bbfc9a27a8e9501ab894d6386e98ddc62bd8762e2d9ab55f89eb87a2f7178
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / yiyimail-1.0.3-py3-none-any.whl
| Download URL | yiyimail-1.0.3-py3-none-any.whl |
|---|---|
| Size | 12.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
69e0607728312be838bcdbb8fd7f3f712877ee970b5639c60c064035e121e556
|
|
BLAKE2b-256 checksum How to use checksums |
90fd55905fb63b7a06cef29b9517d3feaff7df9948d17515073631e76fc2c65f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Security for YIYIMail 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.