Amazon SES as the mail sender
CI / test (push) Successful in 53s
CI / build (push) Successful in 4m32s
CI / deploy (push) Skipped

- worker: without SMTP_URL, the SES SMTP address is built from the AWS
  access key and secret in .env.secrets (several common names, any case);
  the SMTP password is derived from the secret as AWS documents; region
  eu-central-1, port 2587 (DigitalOcean blocks 25/465/587)
- deploy compose: no empty SMTP_URL in the worker's environment (it
  overrode .env.secrets); MAIL_FROM defaults to hello@sorsfonalak.hu
- docs/levelkuldes.md rewritten for SES (domain, DKIM, custom MAIL FROM,
  sandbox, firewall); privacy policy names AWS as the mail processor

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-17 18:43:39 +00:00
co-authored by Claude Opus 5.5
parent 7f761a0f0e
commit 21640ffd9e
11 changed files with 274 additions and 43 deletions
+13 -2
View File
@@ -8,8 +8,11 @@ use lettre::message::Mailbox;
pub struct Config {
pub database_url: String,
/// `smtp://host:port` (plain, e.g. Mailpit), `smtp://user:pass@host:587?tls=required`
/// (STARTTLS) or `smtps://...` (TLS). Unset: e-mails stay in the outbox.
/// (STARTTLS) or `smtps://...` (TLS). Without it, Amazon SES from the AWS
/// variables (see `ses.rs`). Neither: e-mails stay in the outbox.
pub smtp_url: Option<String>,
/// For the log: where the SMTP address came from (no secrets).
pub smtp_about: Option<String>,
/// Sender, e.g. `Sorsfonalak <noreply@sorsfonalak.hu>`.
pub mail_from: Mailbox,
/// Fallback polling interval; new e-mails are picked up at once via LISTEN/NOTIFY.
@@ -44,9 +47,17 @@ where
impl Config {
pub fn from_env() -> anyhow::Result<Self> {
let mail_from = var("MAIL_FROM").unwrap_or_else(|| "Sorsfonalak <noreply@sorsfonalak.local>".into());
let (smtp_url, smtp_about) = match var("SMTP_URL") {
Some(url) => (Some(url), None),
None => match crate::ses::smtp_url(|name| std::env::var(name).ok())? {
Some((url, about)) => (Some(url), Some(about)),
None => (None, None),
},
};
Ok(Self {
database_url: var("DATABASE_URL").context("DATABASE_URL is required")?,
smtp_url: var("SMTP_URL"),
smtp_url,
smtp_about,
mail_from: mail_from.parse().with_context(|| format!("invalid MAIL_FROM '{mail_from}'"))?,
poll_interval: Duration::from_secs(parsed("POLL_INTERVAL_SECS", 30)?),
max_email_attempts: parsed("MAX_EMAIL_ATTEMPTS", 8)?,