EmailWidget - Powerful Email Component Library¶
✨ Features¶
- Lightweight & Compact: Quick installation with no complex dependencies (under 1MB)
- Easy to Use: Clear and simple API, create beautiful email templates with just a few lines of code
- Complete Documentation: Project has comprehensive documentation and type annotations for full IDE support
- Rich Components: Currently includes 15+ beautiful display components, all following Fluent design, viewable below
- Thoroughly Tested: Core functionality is completely tested to ensure project reliability
- Completely Free: Project uses MIT open source license, you can use it freely in any commercial project
✨ Why Choose EmailWidget?¶
Want to send alerts or logs to email but don't know how to beautify them and they look ugly? Use EmailWidget to complete the last step of sending emails!
Want a beautiful email template but don't know HTML/CSS or just too lazy to write? Online templates are difficult to reuse after modification and don't support mobile? Then welcome to try EmailWidget - reusable, responsive, complete type hints, comprehensive documentation, lightweight email component library to help you quickly build your own report templates.
EmailWidget is an email component library designed specifically for Python developers, allowing you to create beautiful HTML email reports with just a few lines of code without needing to understand HTML and CSS details for emails. The project is verified by 1000+ test cases with 100% test coverage for core code, ensuring stability and reliability.
The email style below can be created with just 3 lines of code, and the generated content can be directly sent as email, recipients will also see beautiful emails.
from email_widget import Email
email = Email("欢迎使用EmailWidget")
email.add_card("Python版本", "您需要Python3.10或以上才能使用EmailWidget", metadata={"Python版本": "3.10+"})
email.add_quote("EmailWidget是一个用于构建和发送HTML邮件的Python库。", "EmailWidget")
email.export_html('welcome_email.html')
🚀 Quick Start¶
📦 Installation¶
Create Professional Reports in 30 Seconds¶
from email_widget import Email, TextWidget, ProgressWidget
from email_widget.core.enums import TextType, ProgressTheme
# 创建邮件
email = Email("📊 业务报告")
# 添加标题
email.add_widget(
TextWidget()
.set_content("季度业绩总结")
.set_type(TextType.TITLE_LARGE)
)
# 添加进度指标
email.add_widget(
ProgressWidget()
.set_value(92)
.set_label("目标完成率")
.set_theme(ProgressTheme.SUCCESS)
)
# 导出HTML
email.export_html("report.html")
📊 业务报告
季度业绩总结
🎪 Use Cases¶
🎨 Component Gallery¶
Basic Components¶
# 8种预设样式
email.add_widget(
TextWidget()
.set_content("大标题")
.set_type(TextType.TITLE_LARGE)
)
email.add_widget(
TextWidget()
.set_content("章节标题")
.set_type(TextType.SECTION_H2)
)
email.add_widget(
TextWidget()
.set_content("正文内容,支持多行文本和自动格式化。")
.set_type(TextType.BODY)
)

Advanced Components¶
# 线性进度条
email.add_widget(
ProgressWidget()
.set_value(75)
.set_label("项目进度")
.set_theme(ProgressTheme.PRIMARY)
)
# 圆形进度条
email.add_widget(
CircularProgressWidget()
.set_value(85)
.set_label("完成率")
)

📖 Documentation Navigation¶
🤝 Community & Support¶
Getting Help¶
- 📚 Documentation Center: Complete Documentation
- 🐛 Issue Feedback: GitHub Issues
- 💬 Discussion: GitHub Discussions
- 📧 Email Support: 271374667@qq.com
Contributing¶
We recommend using uv as the package management tool for project management and development
# 1. Clone project
git clone https://github.com/271374667/EmailWidget.git
# 2. Install development environment
uv sync
# 3. Run tests
uv run pytest
# 4. Submit changes
git commit -m "Feature: Add new functionality"
Social Media¶
- GitHub: 271374667/EmailWidget
- Bilibili: Python调包侠
- Email: 271374667@qq.com
📄 License¶
This project uses the MIT License open source license.
⭐ **If this project helps you, please give us a star!** ⭐
Made with ❤️ by Python调包侠