Skip to main content

๐Ÿš€ A modern and user-friendly Python email component library that enables you to easily create beautiful HTML email reports

Project description

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

PyPI version Downloads Python versions License: MIT Codecov

๐Ÿ“– Documentation โ€ข ๐Ÿš€ Quick Start โ€ข ๐Ÿ’ก Examples


โœจ 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')

image-20250706200253564

๐ŸŽจ 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}")
๐ŸŽจ Click to view generated effect

image-20250702215545140

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

image-20250702215350732

Actual Display in Email

Desktop Web Version

๐ŸŽจ Click to view desktop report

Desktop Version

Mobile Version

๐ŸŽจ Click to view mobile report

Mobile Version

๐ŸŽจ 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

๐Ÿ“„ 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

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

emailwidget-0.23.1.tar.gz (3.4 MB view details)

Uploaded Source

Built Distribution

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

emailwidget-0.23.1-py3-none-any.whl (104.2 kB view details)

Uploaded Python 3

File details

Details for the file emailwidget-0.23.1.tar.gz.

File metadata

  • Download URL: emailwidget-0.23.1.tar.gz
  • Upload date:
  • Size: 3.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for emailwidget-0.23.1.tar.gz
Algorithm Hash digest
SHA256 a437e8b88007205ebf00c5ae4bdf33371f3eaf2e4e134e5956e9f45862cf2cdb
MD5 091b815d2f989d003e7b5a9745e80614
BLAKE2b-256 06073fdfc826f2bf8de74ba5b45f0ebe03acade4e6b619204c0a260dc6f977fa

See more details on using hashes here.

Provenance

The following attestation bundles were made for emailwidget-0.23.1.tar.gz:

Publisher: docs-and-publish.yml on 271374667/EmailWidget

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file emailwidget-0.23.1-py3-none-any.whl.

File metadata

  • Download URL: emailwidget-0.23.1-py3-none-any.whl
  • Upload date:
  • Size: 104.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for emailwidget-0.23.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cc0335776309865e9964e2a416f21d195059b4137fdb1dc983f052af69e999a1
MD5 8d4bbe3e09b12ea1a3c08cfa8fe86049
BLAKE2b-256 6a3cc594fd69f3366271afea008839f7d1cf11bafa94bab96c75bbe763616039

See more details on using hashes here.

Provenance

The following attestation bundles were made for emailwidget-0.23.1-py3-none-any.whl:

Publisher: docs-and-publish.yml on 271374667/EmailWidget

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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