mail: treat empty FROM_EMAIL/PUBLIC_BASE_URL as unset
#24 in Riparion/arium — merged 2026-06-03
What
Mailer::from_env now treats a present-but-empty FROM_EMAIL / PUBLIC_BASE_URL the same as an unset var, falling back to the default. The SMTP_HOST guard also trims before the empty check.
Why
Container orchestrators commonly inject present-but-empty env vars rather than leaving them absent — e.g. docker-compose's FROM_EMAIL: ${FROM_EMAIL:-}. The previous std::env::var("FROM_EMAIL").unwrap_or_else(default) only falls back when the var is missing, so an empty value reached "".parse::<Mailbox>(), which is a lettre AddressError::InvalidInput ("Invalid input"). That ? propagated up and panicked the app at boot, producing a crash loop.
This was hit in production (riparion-cms / blog.tonybierman.com): the deploy's compose file added the mail pass-through vars, so FROM_EMAIL went from absent → empty "", and the server crash-looped on every start with:
thread 'main' panicked ... called `Result::unwrap()` on an `Err` value: Invalid input
1: arium::mail::Mailer::from_env
Fix
Filter empty/whitespace-only values back to the default for FROM_EMAIL and PUBLIC_BASE_URL; trim the SMTP_HOST guard so an all-whitespace host falls through to the file backend.
🤖 Generated with Claude Code
Last updated 2026-06-03
Links to this note
Merged pull requests, newest first.