LemonChannels.Adapters.Email.Config (lemon_channels v0.1.0)

View Source

Configuration for the email adapter, from two sources.

  • config :lemon_channels, LemonChannels.Adapters.Email, ... — the channels-native surface, and the one to document for new deployments.
  • the canonical TOML [gateway] config's email block, read through LemonChannels.GatewayConfig.

The TOML source exists because email was configured there for as long as it lived in lemon_gateway. Keeping it readable means an existing deployment's relay credentials, sender address and webhook token survive the cutover without anyone editing a config file. Application env wins on conflict, so a channels-native setting is always the last word.

Lookups accept a key or a path ([:outbound, :relay]) and try the atom key before its string form, since TOML-derived maps are not consistently keyed. first_defined/2 walks a list of those in priority order — the nested outbound/inbound sub-map before the flat alias — which is the resolution order LemonGateway.Transports.Email.Outbound used and its characterization tests pin.

Summary

Functions

Trims a binary and maps the empty result to nil; anything else to nil.

Reads key — an atom or a path of atoms — from a config map.

The first of keys that resolves to a non-nil value.

The merged configuration map.

The shared token the inbound webhook requires, or nil when none is set.

Functions

blank_to_nil(value)

@spec blank_to_nil(term()) :: binary() | nil

Trims a binary and maps the empty result to nil; anything else to nil.

fetch(cfg, key)

@spec fetch(map(), atom() | [atom()]) :: term()

Reads key — an atom or a path of atoms — from a config map.

Returns nil when any segment is missing or a non-final segment is not a map.

first_defined(cfg, keys)

@spec first_defined(map(), [atom() | [atom()]]) :: term()

The first of keys that resolves to a non-nil value.

false counts as defined; only nil moves on to the next key.

get()

@spec get() :: map()

The merged configuration map.

Never raises: an unreachable or malformed source contributes nothing rather than failing the send, because the caller is usually mid-delivery and a missing relay is already reported precisely by Outbound.smtp_options/1.

webhook_token()

@spec webhook_token() :: binary() | nil

The shared token the inbound webhook requires, or nil when none is set.

nil means the endpoint rejects everything — see LemonChannels.Adapters.Email.Webhook.