An expressive email builder for Python
Project description
Python Mailable
Python Mailable is an email builder for Python, inspired by Laravel's Mailable class. It provides a clean and reusable structure for defining, composing, and sending emails with rich context and templates.
[!IMPORTANT]
We currently only support rendering emails, not sending them.This package helps you build and render email content using templates, but you need to handle email sending yourself with your own SMTP client or email delivery service.
Use the
.render()method to get your email body, and then integrate with any mail-sending solution you prefer.
Features
- Define email classes with subjects, recipients, and templates
- Pass context to templates for dynamic rendering
- Attach files easily
- Designed for clarity, testability, and reusability
Usage
Creating a Mailable
To define a custom email, subclass Mailable and implement the build() method. Use the fluent API to configure the mail.
from dataclasses import dataclass
from mailable import Mailable
@dataclass
class OrderShipped(Mailable):
user: User # Your domain model or DTO
def build(self):
return (
self.to(self.user.email)
.subject("Your order has shipped!")
.template("emails/order_shipped.html")
.with_context({"user": self.user})
)
Sending the email
user = User(email="jane.doe@example.com", name="Jane Doe")
email = OrderShipped(user).build()
email.send() # Sends using the built-in SMTP backend
💡 Want to use your own mail client instead?
You can callemail.render()to get the subject, body, and recipient info — and pass that into your own delivery system.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_mailable-0.1.0.tar.gz.
File metadata
- Download URL: python_mailable-0.1.0.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.24
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ca432f399b7aadd063c2501260a10c917964133b87d139a5709d3886911589c
|
|
| MD5 |
10092e5446deffac6dda4d9abdca7954
|
|
| BLAKE2b-256 |
624a3e8a05452bec614099f8c0c66eb7f8439198468ea4fe8b0e565b9c7af739
|
File details
Details for the file python_mailable-0.1.0-py3-none-any.whl.
File metadata
- Download URL: python_mailable-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.24
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df71b56f0eb5fb6c41c3763454c2ecbf66a39e18b0f9ad9e5c0970c4e319eb97
|
|
| MD5 |
c7f80b8a3e5bfaa78ac6354bc05afe8d
|
|
| BLAKE2b-256 |
b4dda6f1d5115a86911f2852b4e3b4e119cdb1e141c9b3f1b7bfbd34df179161
|