util.emailΒΆ
Email utility classes and functions for rendering and sending templates.
AttributesΒΆ
ClassesΒΆ
Represents a template base path with helpers for .txt and .html variants. |
|
Registry of grouped mail templates. |
|
Immutable value object describing one outbound email. |
FunctionsΒΆ
|
|
|
Send a single email with HTML + text alternative (from templates). |
|
Send a plain-text email without using a HTML/txt template pair. |
|
Accept CSV string or iterable; return tuple of non-empty, trimmed emails. |
|
Send multiple template-based emails reusing one SMTP connection. |
Module ContentsΒΆ
- class util.email.MailTemplate[source]ΒΆ
Represents a template base path with helpers for .txt and .html variants.
- class util.email.MailTemplates[source]ΒΆ
Registry of grouped mail templates.
- USER_WELCOME: ClassVar[MailTemplate][source]ΒΆ
- USER_DELETE: ClassVar[MailTemplate][source]ΒΆ
- CERTIFICATE_ISSUED: ClassVar[MailTemplate][source]ΒΆ
- CERTIFICATE_REVOKED: ClassVar[MailTemplate][source]ΒΆ
- GROUPS: ClassVar[collections.abc.Mapping[str, tuple[MailTemplate, Ellipsis]]][source]ΒΆ
- classmethod get_user_templates()[source]ΒΆ
Return the list of user-related templates.
- Return type:
list[MailTemplate]
- classmethod get_certificate_templates()[source]ΒΆ
Return the list of certificate-related templates.
- Return type:
list[MailTemplate]
- classmethod all()[source]ΒΆ
Return all templates for all groups.
- Return type:
list[MailTemplate]
- classmethod get_by_key(key)[source]ΒΆ
Find a template by its key.
- Parameters:
key (str)
- Return type:
MailTemplate | None
- class util.email.EmailPayload[source]ΒΆ
Immutable value object describing one outbound email.
- template_html: MailTemplate[source]ΒΆ
- util.email._render_bodies(tpl, context)[source]ΒΆ
- Parameters:
tpl (MailTemplate)
context (collections.abc.Mapping[str, object])
- Return type:
tuple[str, str]
- util.email.send_email(payload, *, connection=None)[source]ΒΆ
Send a single email with HTML + text alternative (from templates).
- Parameters:
payload (EmailPayload)
connection (Any)
- Return type:
int
- util.email.send_simple(*, subject, body, to, cc=(), bcc=(), from_email=None, connection=None, attachments=())[source]ΒΆ
Send a plain-text email without using a HTML/txt template pair.
- Parameters:
subject (str)
body (str)
to (collections.abc.Iterable[str])
cc (collections.abc.Iterable[str])
bcc (collections.abc.Iterable[str])
from_email (str | None)
connection (Any)
attachments (collections.abc.Iterable[Attachment])
- Return type:
int
- util.email.normalize_addresses(value)[source]ΒΆ
Accept CSV string or iterable; return tuple of non-empty, trimmed emails.
- Parameters:
value (Any)
- Return type:
tuple[str, Ellipsis]
- util.email.send_bulk(payloads)[source]ΒΆ
Send multiple template-based emails reusing one SMTP connection.
- Parameters:
payloads (collections.abc.Iterable[EmailPayload])
- Return type:
int