Reference
Configuration
Configure MailingKit with environment variables through MailingKit.from_env(), with
constructor arguments, or both. Keyword arguments always win over the environment.
Environment variables
Every variable uses the MAILINGKIT_ prefix so it cannot collide with other libraries' MAIL_* settings. Blank values count as unset.
| Variable | Meaning | Default |
|---|---|---|
MAILINGKIT_PROVIDER | console, file, memory, smtp, resend, or a registered plugin | console |
MAILINGKIT_FROM_EMAIL | Default sender address | |
MAILINGKIT_FROM_NAME | Default sender display name | |
MAILINGKIT_TEMPLATES_DIR | Template folder | |
MAILINGKIT_REDIRECT_TO | Send every email to this address instead | |
MAILINGKIT_MAX_ATTEMPTS | Attempts per send for transient failures | 3 |
SMTP
| Variable | Meaning | Default |
|---|---|---|
MAILINGKIT_SMTP_HOST | Server host (required) | |
MAILINGKIT_SMTP_PORT | Server port | 587, 465 or 25 by security |
MAILINGKIT_SMTP_SECURITY | starttls, ssl or none | starttls |
MAILINGKIT_SMTP_USERNAME | Login (set with the password) | |
MAILINGKIT_SMTP_PASSWORD | Password, held as a Secret | |
MAILINGKIT_SMTP_TIMEOUT | Seconds | 30 |
Resend
| Variable | Meaning | Default |
|---|---|---|
MAILINGKIT_RESEND_API_KEY | API key (required) | |
MAILINGKIT_RESEND_BASE_URL | API base URL | https://api.resend.com |
MAILINGKIT_RESEND_TIMEOUT | Seconds | 30 |
Development providers
| Variable | Meaning | Default |
|---|---|---|
MAILINGKIT_FILE_DIR | Output folder for the file provider | .mailingkit/outbox |
MAILINGKIT_CONSOLE_SHOW_HTML | Also print the HTML body | false |
Constructor options
MailingKit(
provider=None, # an EmailProvider; console when omitted
default_sender=None, # "App <no-reply@example.com>" or an Address
templates=None, # a folder path or a TemplateRenderer
retry=None, # RetryPolicy(); NO_RETRY to disable
idempotency_store=None, # InMemoryIdempotencyStore() by default
idempotency_ttl=86400, # seconds a key is remembered
redirect_to=None, # one inbox for every email (staging)
limits=None, # Limits(max_recipients=50, max_message_bytes=10 MiB)
hooks=(), # callables receiving MailEvent
)Configuration problems raise ConfigurationError with the exact variable name, at startup rather than on the first send.