Skip to content

Releases: paramiao/pyMail

pyMail v2.0.0 - Python 3 Migration | Python 3 迁移版本

10 Nov 13:51

Choose a tag to compare

pyMail v2.0.0 - Python 3 Migration 🎉

A complete migration to Python 3 with bug fixes and new features | 完整迁移到 Python 3,修复多个问题并新增功能

⚠️ Breaking Changes | 不兼容变更

  • Requires Python 3.6+ | 需要 Python 3.6+
    • Python 2.7 is no longer supported | 不再支持 Python 2.7
    • Python 2 users: please use the python2 branch (v1.x) | Python 2 用户请使用 python2 分支
  • SendMailDealer.__init__() now requires port parameter | 现在需要 port 参数

🎉 New Features | 新功能

Search Functions | 搜索功能 (Issues #4, #10)

  • getAll() - Get all emails, not just unread | 获取所有邮件,不限于未读
  • searchBySubject(keyword) - Search by subject | 按主题搜索
  • searchBySender(email) - Search by sender | 按发件人搜索
  • searchByDateRange(since, before) - Search by date range | 按日期范围搜索

Error Handling | 错误处理

  • Custom exception classes | 自定义异常类:
    • MailError - Base exception | 基础异常
    • MailAuthError - Authentication failures | 认证失败
    • MailConnectionError - Connection failures | 连接失败
    • MailFetchError - Email fetching failures | 邮件获取失败

Developer Experience | 开发体验

  • Logging support for debugging | 日志支持,便于调试
  • Docstrings for all public methods | 所有公共方法添加文档字符串
  • Better error messages with context | 更清晰的错误提示

🐛 Bug Fixes | 问题修复

Critical | 关键修复

  • Fixed attachment filename handling (Issue #7) | 修复附件文件名处理
    • Sanitize path separators (\, /) | 清洗路径分隔符
    • Remove illegal characters (<>:"|?*) | 移除非法字符
    • Prevent directory traversal attacks | 防止目录遍历攻击
    • Properly decode multi-part encoded filenames | 正确解码多段编码的文件名

Important | 重要修复

  • Fixed reinitMailInfo() (Issue #9) | 修复 reinitMailInfo() 方法
    • Added missing self parameter | 添加缺失的 self 参数
  • Fixed example.py (Issue #8) | 修复示例代码
    • Corrected mailUtils to pyMail | 修正模块名从 mailUtilspyMail
    • Updated to Python 3 syntax | 更新为 Python 3 语法

Improvements | 改进

  • Better encoding handling | 改进编码处理
    • Proper bytes/str conversion | 正确的 bytes/str 转换
    • Use get_content_charset() for decoding | 使用 get_content_charset() 解码
    • Graceful fallback with errors='replace' | 优雅的错误处理
  • Improved header decoding | 改进 Header 解码
    • Use make_header() for multi-segment headers | 使用 make_header() 处理多段编码

📚 Documentation | 文档

New Documentation | 新增文档

  • CHANGELOG.md - Complete changelog | 完整变更日志
  • MIGRATION_GUIDE.md - Step-by-step migration guide | 逐步迁移指南
  • DEVELOPMENT_PLAN.md - Development plan | 开发计划
  • Bilingual README - English/Chinese support | 中英双语 README

Updated Documentation | 更新文档

  • README.md with Python 3 examples | 包含 Python 3 示例
  • Common issues section - Gmail App Passwords, VPN, ports | 常见问题章节
  • Code examples updated to best practices | 示例代码更新为最佳实践

🚀 Migration | 迁移

Quick Start | 快速开始

Most users only need to | 大多数用户只需:

  1. Upgrade to Python 3.6+ | 升级到 Python 3.6+
  2. Add port parameter to SendMailDealer (if using SMTP) | 添加 port 参数(如使用 SMTP)
    # Old | 旧代码
    sml = SendMailDealer(user, passwd, smtp)
    
    # New | 新代码  
    sml = SendMailDealer(user, passwd, smtp, 587, usettls=True)
  3. Enjoy new features! | 享受新功能!

Detailed Guide | 详细指南

See MIGRATION_GUIDE.md for:

  • API changes checklist | API 变更清单
  • Code migration examples | 代码迁移示例
  • Rollback procedures | 回滚步骤

查看迁移指南了解更多细节。

🙏 Acknowledgments | 致谢

Special thanks to all contributors who reported issues | 特别感谢所有报告问题的贡献者:

📊 Statistics | 统计

  • 10 files changed | 10 个文件修改
  • 2,419 insertions(+) | 新增 2,419 行
  • 258 deletions(-) | 删除 258 行
  • 6 issues resolved | 解决 6 个问题
  • 100% test pass rate | 100% 测试通过率

🔗 Links | 链接


Note | 注意: This release requires Python 3.6 or higher. For Python 2 support, use the python2 branch | 本版本需要 Python 3.6 或更高版本。如需 Python 2 支持,请使用 python2 分支。