Skip to content

Installation

New to Python Mailable? Start with the Introduction for an overview of what it does and why.

  • Python 3.13+
  • Jinja2 for template rendering

Add it to your project with your dependency manager of choice:

Terminal window
uv add python-mailable

or

Terminal window
pip install python-mailable

Subclass Mailable and implement build():

from dataclasses import dataclass
from python_mailable.mailable import Mailable
@dataclass
class OrderShipped(Mailable):
user: User
def build(self):
return (
self.to(self.user.email)
.subject("Your order has shipped!")
.template("emails/order_shipped.html.j2")
.with_context({"user": self.user})
)
email = OrderShipped(user).build()
html = email.render()