Cockatrice/servatrice/src
BruebachL 8968709642
[SMTP] Add reliable email delivery with retry and database-backed queue (#7240)
* [SMTP] Add reliable email delivery with retry and database-backed queue

Rework the SMTP client from fire-and-forget sending into a persistent
queue with exponential backoff and per-message retry budget, backed by
the existing database rows as the durable source of truth.

- Keep pending emails in an in-memory queue with attempts/backoff
  tracking; enqueue without deleting database rows, and only remove the
  row once delivery is confirmed via the mailDelivered signal.
- Add exponential backoff (doubling, capped at 30 min) between delivery
  attempts, bounded by new smtp/maxretries and smtp/retrydelay settings.
- Track connection-layer failures (connect/auth/encrypt) with their own
  backoff; route failures to recordFailed/recordConnectionFailure so
  undeliverable mail eventually drops from the queue instead of
  retrying forever.
- Treat rejected recipients/senders as permanent failures.
- Rebuild the SMTP buffer from the authoritative queue before each send
  via a new QxtSmtp::reset() so reconnects never duplicate deliveries.
- Start the idle timeout after authentication, not on TCP connect, so
  slow SSL/STARTTLS handshakes are not cut short.

* [SMTP] Fix retry accounting, backoff reset, and token dedupe

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
2026-10-11 20:59:32 +02:00
..
smtp [SMTP] Add reliable email delivery with retry and database-backed queue (#7240) 2026-10-11 20:59:32 +02:00
deck_tag_serialization.h [Server] Add deck share links and public deck visibility (#7241) 2026-09-20 20:22:16 +02:00
email_parser.cpp [Tooling] Apply include-what-you-use across the tree (#7396) 2026-10-08 11:13:50 +02:00
email_parser.h Fix #4903: Parse Email Addresses whenever used (#4932) 2023-12-09 00:52:47 -05:00
event_loop_watchdog.cpp [Tooling] Apply include-what-you-use across the tree (#7396) 2026-10-08 11:13:50 +02:00
event_loop_watchdog.h [Tooling] Apply include-what-you-use across the tree (#7396) 2026-10-08 11:13:50 +02:00
isl_interface.cpp [Security] Harden network input handling and websocket proxying (#7076) 2026-10-08 23:18:47 +02:00
isl_interface.h [Tooling] Apply include-what-you-use across the tree (#7396) 2026-10-08 11:13:50 +02:00
main.cpp [Tooling] Apply include-what-you-use across the tree (#7396) 2026-10-08 11:13:50 +02:00
main.h Refactor servatrice email send 2015-07-25 18:48:34 +02:00
metrics_registry.cpp [Tooling] Apply include-what-you-use across the tree (#7396) 2026-10-08 11:13:50 +02:00
metrics_registry.h [Tooling] Apply include-what-you-use across the tree (#7396) 2026-10-08 11:13:50 +02:00
servatrice.cpp [SMTP] Add reliable email delivery with retry and database-backed queue (#7240) 2026-10-11 20:59:32 +02:00
servatrice.h [SMTP] Add reliable email delivery with retry and database-backed queue (#7240) 2026-10-11 20:59:32 +02:00
servatrice_connection_pool.cpp clangify everything with the new header sorting (#3908) 2020-03-18 17:36:02 -04:00
servatrice_connection_pool.h [Tooling] Apply include-what-you-use across the tree (#7396) 2026-10-08 11:13:50 +02:00
servatrice_database_interface.cpp [Tooling] Apply include-what-you-use across the tree (#7396) 2026-10-08 11:13:50 +02:00
servatrice_database_interface.h [Tooling] Apply include-what-you-use across the tree (#7396) 2026-10-08 11:13:50 +02:00
server_logger.cpp [Tooling] Apply include-what-you-use across the tree (#7396) 2026-10-08 11:13:50 +02:00
server_logger.h [Tooling] Apply include-what-you-use across the tree (#7396) 2026-10-08 11:13:50 +02:00
serversocketinterface.cpp [Report] Add context menu to report queue rows (#7444) 2026-10-11 15:33:47 +02:00
serversocketinterface.h [Report] Add report reopen action for closed reports (#7442) 2026-10-11 15:28:45 +02:00
settingscache.cpp [Tooling] Apply include-what-you-use across the tree (#7396) 2026-10-08 11:13:50 +02:00
settingscache.h [Tooling] Apply include-what-you-use across the tree (#7396) 2026-10-08 11:13:50 +02:00
signalhandler.cpp [Tooling] Apply include-what-you-use across the tree (#7396) 2026-10-08 11:13:50 +02:00
signalhandler.h [Tooling] Apply include-what-you-use across the tree (#7396) 2026-10-08 11:13:50 +02:00
smtpclient.cpp [SMTP] Add reliable email delivery with retry and database-backed queue (#7240) 2026-10-11 20:59:32 +02:00
smtpclient.h [SMTP] Add reliable email delivery with retry and database-backed queue (#7240) 2026-10-11 20:59:32 +02:00