Factory¶
factory
¶
Email client factory.
Provides factory functions for creating email client instances based on configuration. Supports custom email client registration.
Classes¶
Functions¶
register_email_client
¶
register_email_client(
backend_name: str, client_class: Type[EmailClient]
) -> None
Register a custom email client backend.
This allows users to add their own email client implementations without modifying the FastAuth library code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend_name |
str
|
Name to identify this backend (used in settings.email_backend) |
required |
client_class |
Type[EmailClient]
|
EmailClient subclass to use for this backend |
required |
Example
from fastauth.email.factory import register_email_client from fastauth.email.base import EmailClient
class MyCustomEmailClient(EmailClient): ... def send_verification_email(self, *, to: str, token: str) -> None: ... # Custom implementation ... pass
register_email_client("custom", MyCustomEmailClient)
Source code in fastauth/email/factory.py
get_email_client
¶
get_email_client() -> EmailClient
Get email client based on settings.email_backend.
Returns:
| Type | Description |
|---|---|
EmailClient
|
An instance of the configured email client. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the configured backend is not registered. |