Language: English | ็ฎไฝไธญๆ
EmailWidget - Powerful Email Component Library
๐ A modern, easy-to-use Python email component library that lets you effortlessly create beautiful HTML email reports
โจ Features
- Small & Lightweight: Quick installation, no complex dependencies (less than 1MB)
- Easy to Use: Clear and simple API, create beautiful email templates with just a few lines of code
- Complete Documentation: Full documentation with type annotations, comprehensive IDE support
- Rich Components: Currently includes 17 beautiful display components, all following Fluent design principles
- Fully Tested: Core functionality thoroughly tested to ensure reliability
- Completely Free: MIT open source license, use freely in any commercial project
โจ Why Choose EmailWidget?
Want to send alerts or logs to email but don't know how to beautify them? Use EmailWidget to complete the final step of sending emails!
5 lines of code saves you 30 minutes of dealing with various email CSS compatibility issues. Supports PC and mobile devices, making the once painful task of sending alert emails simple. You can build your unique email template like building blocks, send with one line of code, no heavyweight dependencies, completely open source and free for commercial use. Installation is less than 2MB. EmailWidget welcomes you to join your project anytime.
The email style below can be created with just 3 lines of code, and the generated content can be sent directly as an email, with recipients seeing beautiful emails:
from email_widget import Email
email = Email("Welcome to EmailWidget")
email.add_card("Python Version", "You need Python 3.10 or higher to use EmailWidget", metadata={"Python Version": "3.10+"})
email.add_quote("EmailWidget is a Python library for building and sending HTML emails.", "EmailWidget")
email.export_html('welcome_email.html')
๐จ Rich Components - 17 Intuitive Components
# One line of code, multiple components
email.add_widget(TextWidget().set_content("Title").set_type(TextType.TITLE_LARGE))
email.add_widget(TableWidget().set_dataframe(df)) # Supports pandas DataFrame
email.add_widget(ChartWidget().set_chart(plt)) # Supports matplotlib/seaborn charts
email.add_widget(ProgressWidget().set_value(85).set_theme(ProgressTheme.SUCCESS))
# Use shortcut methods to add components directly
email.add_progress(value=95, max_value=100)
| ๐ฏ Component Type | ๐ Features | ๐ง Use Cases |
|---|---|---|
| ๐ TextWidget | 8 text styles, auto-numbering, section management | Titles, body text, descriptions |
| ๐ TableWidget | DataFrame integration, status cells, color coding | Data tables, statistical reports |
| ๐ ChartWidget | Native matplotlib/seaborn support, auto-encoding | Data visualization, trend charts |
| ๐ ProgressWidget | 5 themes, increment/decrement, percentage display | Task progress, completion rates |
| โญ CircularProgressWidget | Circular progress bars, multiple sizes, dynamic updates | KPI metrics, completion rates |
| ๐ด CardWidget | Info cards, icon support, metadata management | Summary info, status display |
| โ ๏ธ AlertWidget | 5 alert types, custom icons, message notifications | Notifications, warnings, tips |
| ๐ผ๏ธ ImageWidget | Multi-source support, size control, description text | Image display, logo display |
| ๐ฌ QuoteWidget | Quote styles, author info, source attribution | Quotes, comments, excerpts |
| ๐ StatusWidget | Status item management, layout control, dynamic updates | System status, service monitoring |
| ๐ ColumnWidget | Auto/manual columns, responsive layout, widget management | Multi-column layout, content grouping |
| ๐ LogWidget | Log levels, syntax highlighting, filtering | System logs, runtime records |
| ๐ ButtonWidget | Link buttons, custom styles, multiple themes | Action buttons, navigation links |
| ๐ SeparatorWidget | Dividers, multiple styles, customizable colors | Content separation, area division |
| โ ChecklistWidget | Task lists, status tracking, progress statistics | To-do items, checklists |
| โฐ TimelineWidget | Timeline display, event management, status markers | Progress tracking, history records |
| ๐ MetricWidget | Data metrics, trend analysis, multiple layouts | KPI display, data monitoring |
๐โโ๏ธ Quick Start
๐ฆ Installation
Basic Installation (Recommended)
pip install EmailWidget
๐ก Installation Note: Only requires jinja2 dependency, lightweight and fast. If you need DataFrame functionality for TableWidget or Matplotlib for ChartWidget, please install pandas or matplotlib/seaborn separately.
๐ฏ Create Your First Report in 30 Seconds
from email_widget import Email, TextWidget, ProgressWidget
from email_widget.core.enums import TextType, ProgressTheme
# 1๏ธโฃ Create email object
email = Email("๐ Daily Sales Report")
# 2๏ธโฃ Add subtitle and footer
email.set_subtitle("Q1 2024 Performance Summary")
email.set_footer("This report is automatically generated by the data analysis team")
# 3๏ธโฃ Add a large title
email.add_widget(
TextWidget().set_content("๐ Sales Performance Overview").set_type(TextType.TITLE_LARGE)
)
# 4๏ธโฃ Add progress indicators
email.add_widget(
ProgressWidget()
.set_value(92)
.set_label("Quarterly Goal Completion Rate")
.set_theme(ProgressTheme.SUCCESS)
)
# 5๏ธโฃ Add data table (using convenience method, directly call email instead of creating widget then add_widget)
data = [
["iPhone 15", "1,250", "$1,875,000", "125%"],
["MacBook Pro", "580", "$1,740,000", "116%"],
["iPad Air", "920", "$552,000", "108%"],
]
email.add_table_from_data(
data=data, headers=["Product", "Sales", "Revenue", "Achievement Rate"], title="๐ Product Sales Details"
)
# 6๏ธโฃ Export HTML file
file_path = email.export_html("daily_report.html")
# If you need to send email directly, export to string interface is also provided (images are automatically converted to base64 embedded in html)
# html_str: str = email.export_str()
print(f"๐ Report generated: {file_path}")
Quick Send
EmailWidget includes a basic email sending function. You can quickly send emails through the EmailSender class, currently supporting QQ Email and NetEase Email.
Before using, you need to obtain the account and key from the respective email providers. Here's a simple example of sending an email by importing QQEmailSender and configuring the account and key:
from email_widget import Email, QQEmailSender
email = Email("Test Email")
email.add_card("Test Card", "This is test card content.")
email.add_quote("This is a quote text.", "PythonImporter")
email.add_status_items(
[{"label": "Status1", "value": "Complete"}, {"label": "Status2", "value": "In Progress"}],
title="Test Status",
)
email.add_table_from_data(
[["Column1", "Column2"], ["Data1", "Data2"]],
title="Test Table",
)
QQEmailSender(username="your_email@qq.com", password="your_key").send(email)
print("Email sent successfully!")
๐ง Component Showcase
Below are displays of all currently available components (some features may not be updated timely, please refer to documentation if there are errors or inconsistencies):
๐จ Click to view component preview
Actual Display in Email
Desktop Web Version
๐จ Click to view desktop report
Mobile Version
๐จ Click to view mobile report
๐จ Advanced Features
๐ฏ Method Chaining Support
# Fluent API design
email = (Email("Project Progress Report")
.set_subtitle("Q1 Summary")
.set_footer("Generated by EmailWidget")
.add_widget(TextWidget().set_content("Overview").set_type(TextType.TITLE_LARGE))
.add_widget(ProgressWidget().set_value(78).set_label("Overall Progress")))
๐ Learning Resources
| ๐ Resource Type | ๐ Link | ๐ Content |
|---|---|---|
| ๐ Quick Start | Installation Guide | Environment setup, first email |
| ๐ User Manual | Component Guide | Complete tutorial for 17 components |
| ๐ง API Docs | API Reference | Complete class and method documentation |
| ๐ก Examples | Use Cases | Real-world scenario code |
| ๐ ๏ธ Dev Guide | Contributing | Participate in project development |
๐ค Community & Contributing
๐ Participate in Open Source
# Clone project
git clone https://github.com/271374667/EmailWidget.git
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest tests/
# Submit code
git add .
git commit -m "feat: add new feature"
๐ Contact Us
- ๐ Bug Reports: GitHub Issues
- ๐ฌ Discussion: GitHub Discussions
- ๐ง Email: 271374667@qq.com
- ๐บ Video Tutorials: Bilibili Channel
๐ License
This project is licensed under the MIT License.
โญ If this project helps you, please give us a Star! โญ
Made with โค๏ธ by Python ่ฐๅ ไพ | Watch Tutorials | View Documentation
Release files for EmailWidget 0.23.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| emailwidget-0.23.1.tar.gz | 3.4 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| emailwidget-0.23.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 3.5 MB
Release files / emailwidget-0.23.1.tar.gz
| Download URL | emailwidget-0.23.1.tar.gz |
|---|---|
| Size | 3.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a437e8b88007205ebf00c5ae4bdf33371f3eaf2e4e134e5956e9f45862cf2cdb
|
|
BLAKE2b-256 checksum How to use checksums |
06073fdfc826f2bf8de74ba5b45f0ebe03acade4e6b619204c0a260dc6f977fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2025.
Transparency logRelease files / emailwidget-0.23.1-py3-none-any.whl
| Download URL | emailwidget-0.23.1-py3-none-any.whl |
|---|---|
| Size | 104.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cc0335776309865e9964e2a416f21d195059b4137fdb1dc983f052af69e999a1
|
|
BLAKE2b-256 checksum How to use checksums |
6a3cc594fd69f3366271afea008839f7d1cf11bafa94bab96c75bbe763616039
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2025.
Transparency log