Built-ins
EmailProviderDefinition
Describe an email transport and the fields required to connect an account.
The registry resolves the transport from the provider ID stored on the account. The definition controls setup fields, defaults, authorization, and synchronization capabilities.
| Setting | Type | Default | Description |
|---|---|---|---|
id | str | Required | Stable ID stored on email accounts that use this provider. |
documentation | str | '' | Markdown and tagged examples included in the generated developer reference. |
name | str | Required | Name shown when adding an email account. |
description | str | Promise | Required | Summary of the provider's supported transport. |
icon | str | Required | Icon shown for this provider. |
adapter_class | type[BaseEmailAdapter] | Required | Transport adapter class for incoming and outgoing email. |
fields | list[str] | [] | Connection form fields offered by this provider. |
required_fields | list[str] | [] | Connection form fields that must be supplied. |
initial | dict[str, Any] | {} | Initial connection form values. |
setup_instructions | str | None | None | Setup instructions shown to the account owner. |
sync_capabilities | EmailSyncCapability | Factory: EmailSyncCapability | Sync features implemented by this provider. |
authorization | Optional[Annotated[EmailAuthorizationDefinition, SkipValidation()]] | None | OAuth setup metadata when the provider uses authorization. |
mailbox_defaults | Callable[[BaseEmailAdapter], dict[str, dict[str, Any]]] | None | None | Callback that supplies initial folder settings for a connected mailbox. |
Add an account preset for a known mail server
Reuse the IMAP and SMTP adapter. Use the example hosts as placeholders for your organization’s servers.
python
from bloomerp.communication.builtins.emails.email_providers import EmailProvider
from bloomerp.communication.builtins.emails.provider_definition import EmailProviderDefinition
from bloomerp.communication.builtins.emails.registry import EMAIL_PROVIDER_REGISTRY
imap = EmailProvider.IMAP.value
operations = EmailProviderDefinition(
id="example_operations_mail",
name="Operations mail",
description="IMAP and SMTP setup for operations mailboxes.",
icon=imap.icon,
adapter_class=imap.adapter_class,
fields=imap.fields,
required_fields=imap.required_fields,
initial={"imap_host": "imap.example.com", "smtp_host": "smtp.example.com"},
)
EMAIL_PROVIDER_REGISTRY.register("EXAMPLE_OPERATIONS_MAIL", operations)Set the polling interval for a provider preset
Keep the original transport and account fields while publishing a different polling default.
python
from bloomerp.communication.builtins.emails.email_providers import EmailProvider
from bloomerp.communication.builtins.emails.provider_definition import EmailSyncCapability
from bloomerp.communication.builtins.emails.registry import EMAIL_PROVIDER_REGISTRY
archive_mail = EmailProvider.IMAP.value.model_copy(
update={
"id": "example_archive_mail",
"name": "Archive mail",
"sync_capabilities": EmailSyncCapability(default_poll_interval_minutes=15),
},
)
EMAIL_PROVIDER_REGISTRY.register("EXAMPLE_ARCHIVE_MAIL", archive_mail)Microsoft 365 / Outlook
ID outlook · Lookup ID OUTLOOK
Connect a mailbox with delegated Microsoft Graph authorization.
| Field | Value |
|---|---|
icon | fa-brands fa-microsoft |
setup_instructions | <div class="space-y-2 text-sm text-slate-600"> <p>Enter your Microsoft Entra application's client ID, client secret value and directory tenant ID, then sign in to authorize this mailbox.</p> <ul class="list-disc space-y-1 pl-5"> <li>Register the callback below as a Web redirect URI. This page must use HTTPS.</li> <li>Configure delegated User.Read, Mail.ReadWrite and Mail.Send permissions. Your organization may require administrator consent.</li> <li>Use the tenant UUID for the mailbox organization. Mailbox passwords are not needed.</li> <li>Disconnect removes local mailbox tokens. Revoke consent separately in Microsoft if needed.</li> </ul> </div> |
IMAP / SMTP
ID imap · Lookup ID IMAP
Connect a mailbox with incoming and outgoing server credentials.
| Field | Value |
|---|---|
icon | fa-solid fa-envelope-open-text |
setup_instructions | <div class="space-y-2 text-sm text-slate-600"> <p>Use the incoming and outgoing server settings provided by the mailbox host.</p> <ul class="list-disc space-y-1 pl-5"> <li>Enter the mailbox address and, when different, the login username.</li> <li>Use an app password when the provider requires one for IMAP or SMTP access.</li> <li>Enter the IMAP host, port, and security mode for incoming mail.</li> <li>Enter the SMTP host, port, and security mode for outgoing mail.</li> <li>For an alias, set the SMTP envelope sender to the primary mailbox address if your provider requires it. Leave it blank otherwise. Some providers display the primary mailbox as sending on behalf of the alias.</li> </ul> </div> |
