On 23 November the TLS certificate on my mail server expired, and phones stopped connecting to IMAP and mail submission. The renewal itself had worked. Traefik renewed the Let's Encrypt certificate 30 days before expiry, and a small container copied the new file to where the mail server (Stalwart) reads it. But Stalwart reads that file once, at start, and it had been running for five weeks. The new certificate sat on disk while ports 993, 465 and 587 kept serving the old one, and it stayed that way for two days until a restart.

Two things hid it. My own tools talk to the mail server over HTTPS through Traefik, which had the new certificate. And incoming mail kept arriving, because servers delivering mail to each other do not verify the certificate.

The fix is a cron script that runs every hour. It compares the certificate file with what 993 and 465 actually present, and on a mismatch it calls Stalwart's reload endpoint, which swaps the certificate without a restart and keeps open connections. It also reports to the uptime monitor, which goes down if a port still presents the old certificate after a reload or has under 14 days left.

One trap from testing: with a certificate that has no Subject Alternative Name, the reload answered "Success" and kept serving the old certificate. Let's Encrypt certificates always carry one, but a self-signed test certificate may not.

The general check: for every service that serves TLS from a file, find out when it reads the file. A successful renewal job only tells you the file is new.