PhoenixKit.Emails.Utils (phoenix_kit v1.6.16)

View Source

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.

Functions

adapter_to_provider_name(adapter, default_name \\ "unknown")

@spec adapter_to_provider_name(module() | nil, String.t()) :: String.t()

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.Emails.Utils.adapter_to_provider_name(Swoosh.Adapters.AmazonSES, "unknown")
"aws_ses"

iex> PhoenixKit.Emails.Utils.adapter_to_provider_name(Swoosh.Adapters.SMTP, "unknown")
"smtp"

iex> PhoenixKit.Emails.Utils.adapter_to_provider_name(Some.Custom.Adapter, "custom")
"custom"

detect_provider_from_config()

@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.Emails.Utils.detect_provider_from_config()
"aws_ses"

iex> PhoenixKit.Emails.Utils.detect_provider_from_config()
"smtp"