Mail: timeout per stap met fase en verstreken tijd in het log
De SMTP-verzender gaf alle stappen samen een tijdsbudget; nu krijgt elke stap (verbinden met STARTTLS, inloggen, versturen) zijn eigen volledige timeout. Bij een timeout noemt de code de stap (timeout_connect, timeout_auth, timeout_send) en toont het log per stap de verstreken milliseconden. TimeoutSeconds blijft instelbaar (standaard 10), bereik nu 1 tot 120. Infra-doc met veiligheidsmodus, timeout en leeswijzer voor het journal. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
+8
@@ -61,3 +61,11 @@ The `From:` address of every mail is decided in this order: (1) the sender chose
|
||||
**So for `mail.andreaslop.nl` the ASF host must set**, in `shared/env`: `Email__FromAddress=<an address on andreaslop.nl>` and `Email__AllowedFromAddresses__0=<the same address>` (plus `Email__FromName`), where that address is one the SMTP account is allowed to use as sender. With the default `no-reply@slpsoftware.nl` the server is likely to refuse the sender (error code `rejected_sender`, SMTP 5xx at MAIL FROM) or not relay it. A change of the committed ASF default to an `@andreaslop.nl` address is a decision for Bryan (not made).
|
||||
|
||||
**Diagnosis in the log** (Pi-Main journal): at start `mail_status enabled=true smtp_host=... smtp_port=... starttls=... default_from_domain=...`; per failed mail `identity_mail_failed code=... detail=... from_domain=... smtp_port=...`, where `detail` for a refused command is `SmtpCommandException phase=SenderNotAccepted|RecipientNotAccepted|MessageNotAccepted smtp_status=<name>(<number>) reply="<first line of the server reply, addresses replaced by [adres], at most 120 characters>"`. The codes shown to the administrator: `rejected_sender`, `rejected_recipient`, `rejected`, `auth_failed`, `tls_failed`, `connection_failed`, `timeout`, `not_configured`, `unknown`. Never logged: credentials, addresses, tokens, links, the rest of a server reply.
|
||||
|
||||
## SMTP connection, security mode and timeouts (update 2026-11-09, for the Pi-Main journal questions)
|
||||
- **Security mode**: `Email__Smtp__EnableSsl=true` (the default) means MailKit `SecureSocketOptions.StartTls` (plain connection, then the STARTTLS upgrade; the normal setting for port 587). `false` means no encryption at all (`SecureSocketOptions.None`, only for a local catcher such as smtp4dev). Implicit TLS (port 465) is not supported.
|
||||
- **Authentication**: only when `Email__Smtp__Username` is set (then the password is required); MailKit picks the strongest mechanism the server offers.
|
||||
- **Timeout**: `Email__Smtp__TimeoutSeconds`, default **10**, allowed **1 to 120** (a value outside that switches mail off at start-up with an Error line naming the setting). It applies to EACH step separately (connect including the STARTTLS upgrade, login, send), so a slow login no longer uses up the time of the send; the worst case for one mail is three times the value. An administrator's request waits for it, so keep it modest; raise it (for example to 30) when the server is slow to log in.
|
||||
- **Per environment**: every SMTP setting lives in that host's `shared/env` (host, port, EnableSsl, username, password, timeout, `App__PublicBaseUrl`); hosts can differ (SlpSoftware `mail.slpsoftware.nl`, ASF probably `mail.andreaslop.nl`).
|
||||
- **Reading a failure in the journal**: `identity_mail_failed code=<code> detail=... phase=<connect|auth|send> timings="connect=120ms auth=4800ms(failed)" timeout_per_phase_s=10 from_domain=... smtp_port=...`. `timings` lists every step that ran and how long it took in milliseconds; the step marked `(failed)` is where it went wrong. MailKit does the STARTTLS upgrade inside the connect step, so "connect" covers the TCP connection, the greeting and the TLS upgrade together. Timeout codes: `timeout_connect`, `timeout_auth`, `timeout_send` (the screen text names the step). For a refused command the `detail` already holds the phase, the SMTP status code and the redacted first line of the server reply (since daaadcb). Nothing in the line is secret: no credentials, no addresses, no tokens.
|
||||
- **Typical readings**: `auth_failed` with `phase=AUTH` = wrong username or password (and repeated failures can make a server throttle or block the client address, for example fail2ban); `timeout_auth` = the server accepted the connection but took too long to answer the login (slow authentication backend, or a throttle); `timeout_connect` = no greeting or STARTTLS in time (firewall, wrong port, server down); `timeout_send` = the server stalled while taking the message.
|
||||
|
||||
Reference in New Issue
Block a user