Skip to main content

A high-performance, modern Python library for email processing (IMAP/POP3/SMTP).

Project description

YIYIMail Logo

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 ID command 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 and save()/load() for local persistence.
  • Type Safe: Fully typed with Python 3.7+ type hints.

📦 Installation

# Just copy the YIYIMail folder into your project.
import 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yiyimail-1.0.1.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yiyimail-1.0.1-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file yiyimail-1.0.1.tar.gz.

File metadata

  • Download URL: yiyimail-1.0.1.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for yiyimail-1.0.1.tar.gz
Algorithm Hash digest
SHA256 c56af828cae3d7a10f7dba9c78a62abdbb55bd36431cd4cd95d9c1a400c7bfa2
MD5 2c136fb29c43afa43693dbf02b8a9c34
BLAKE2b-256 ed5811bbc9a89f77e8e9df3186fc65ad7033e1debb7197b7680aa857771e429a

See more details on using hashes here.

File details

Details for the file yiyimail-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: yiyimail-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for yiyimail-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 94ed594d5acfc364e6e9b208f7292d520f21f38568bbb9d0e156a7b5d2639d32
MD5 69752b2f796f0b9159a827dc5504f534
BLAKE2b-256 089759d0e44c81f6f60c93e75ad33315f5100a92efec95614e369309f557d1ff

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page