Utility functions for email handling in PhoenixKit.
This module contains helper functions for email provider detection, configuration analysis, and other email-related utilities.
Summary
Functions
Converts Swoosh adapter module to provider name.
Detects email provider from application configuration.
Reports exactly what mailer adapter is configured and where, for display in the admin UI.
Functions
Converts Swoosh adapter module to provider name.
Maps common Swoosh mailer adapters to standardized provider names used throughout PhoenixKit's email tracking system.
Parameters
adapter- The Swoosh adapter module (e.g., Swoosh.Adapters.AmazonSES)default_name- Default provider name to return if adapter is unknown
Examples
iex> PhoenixKit.Modules.Emails.Utils.adapter_to_provider_name(Swoosh.Adapters.AmazonSES, "unknown")
"aws_ses"
iex> PhoenixKit.Modules.Emails.Utils.adapter_to_provider_name(Swoosh.Adapters.SMTP, "unknown")
"smtp"
iex> PhoenixKit.Modules.Emails.Utils.adapter_to_provider_name(Some.Custom.Adapter, "custom")
"custom"
@spec detect_provider_from_config() :: String.t()
Detects email provider from application configuration.
Analyzes the configured mailer adapter to determine which email provider is being used (AWS SES, SMTP, SendGrid, etc.).
Examples
iex> PhoenixKit.Modules.Emails.Utils.detect_provider_from_config()
"aws_ses"
iex> PhoenixKit.Modules.Emails.Utils.detect_provider_from_config()
"smtp"
@spec mailer_adapter_status() :: %{ mailer: module(), adapter: module() | nil, provider: String.t(), config_app: atom(), config_module: module() }
Reports exactly what mailer adapter is configured and where, for display in the admin UI.
Mirrors PhoenixKit.Mailer.deliver_email/2's own resolution logic (built-in
vs. delegated mailer, config read from the right otp_app) so what this
reports can never diverge from what actually sends mail — including the
delegation-mode case where the host app supplies its own mailer module
under its own otp_app.
Examples
iex> PhoenixKit.Modules.Emails.Utils.mailer_adapter_status()
%{mailer: PhoenixKit.Mailer, adapter: Swoosh.Adapters.AmazonSES,
provider: "aws_ses", config_app: :phoenix_kit, config_module: PhoenixKit.Mailer}