feat(mailer): send email through plain SMTP #51

Manually merged
jfro merged 2 commits from feat/47-smtp into main 2026-11-10 21:08:10 +00:00
Owner

Closes #47.

Adds plain SMTP as a second mailer next to Mailgun, as approved in D7. Like Mailgun, it's set with env vars only:

Variable
SMTP_HOST Turns SMTP on. Needs MAIL_FROM.
SMTP_TLS starttls (default), tls (implicit TLS), or none. With TLS, the server's certificate and hostname are checked against the system's CAs.
SMTP_PORT Default 587, 465 with tls, 25 with none.
SMTP_USERNAME, SMTP_PASSWORD Optional login. Without a username, no AUTH is attempted.

Boot fails with a clear message when SMTP_HOST and MAILGUN_* are both set, when MAIL_FROM is missing with SMTP, or when SMTP_TLS/SMTP_PORT is malformed. The README, the registration and email-channel messages, and the Mailer docs now name both mailers.

Dependencies: gen_smtp 1.3.0 (approved), plus its own dependency ranch 2.4.0 (ninenines, Cowboy's socket pool). Only gen_smtp's client is used.

Checks

  • mix precommit is clean (820 tests). New runtime-config tests cover STARTTLS defaults with verification, implicit TLS with login and port, none with a custom port, and the four boot errors.
  • End to end against a local aiosmtpd, with the config built from config/runtime.exs: SMTP_TLS=none delivers. STARTTLS to a server with an untrusted certificate is refused (selfsigned_peer/tls_failed). With a test CA added to the system store, STARTTLS delivers over TLS.
Closes #47. Adds plain SMTP as a second mailer next to Mailgun, as approved in D7. Like Mailgun, it's set with env vars only: | Variable | | |---|---| | `SMTP_HOST` | Turns SMTP on. Needs `MAIL_FROM`. | | `SMTP_TLS` | `starttls` (default), `tls` (implicit TLS), or `none`. With TLS, the server's certificate and hostname are checked against the system's CAs. | | `SMTP_PORT` | Default 587, 465 with `tls`, 25 with `none`. | | `SMTP_USERNAME`, `SMTP_PASSWORD` | Optional login. Without a username, no AUTH is attempted. | Boot fails with a clear message when `SMTP_HOST` and `MAILGUN_*` are both set, when `MAIL_FROM` is missing with SMTP, or when `SMTP_TLS`/`SMTP_PORT` is malformed. The README, the registration and email-channel messages, and the Mailer docs now name both mailers. **Dependencies:** `gen_smtp` 1.3.0 (approved), plus its own dependency `ranch` 2.4.0 (ninenines, Cowboy's socket pool). Only gen_smtp's client is used. ## Checks - `mix precommit` is clean (820 tests). New runtime-config tests cover STARTTLS defaults with verification, implicit TLS with login and port, `none` with a custom port, and the four boot errors. - End to end against a local aiosmtpd, with the config built from `config/runtime.exs`: `SMTP_TLS=none` delivers. STARTTLS to a server with an untrusted certificate is refused (`selfsigned_peer`/`tls_failed`). With a test CA added to the system store, STARTTLS delivers over TLS.
feat(mailer): send email through plain SMTP
All checks were successful
CI / test (pull_request) Successful in 1m15s
090631d290
SMTP_HOST turns on Swoosh's SMTP adapter (gen_smtp), with SMTP_TLS
(starttls by default, tls, or none; certificates checked against the
system's CAs), SMTP_PORT (587/465/25 by mode), and an optional
SMTP_USERNAME/SMTP_PASSWORD. MAIL_FROM is required with SMTP. Boot fails
with a clear message when both SMTP_HOST and MAILGUN_* are set.

Closes #47
fix(mailer): treat an empty SMTP_PORT or SMTP_TLS as unset
All checks were successful
CI / test (pull_request) Successful in 1m15s
4a4c0cf51a
jfro manually merged commit 307509b461 into main 2026-11-10 21:08:10 +00:00
Sign in to join this conversation.
No description provided.