All notes

Proxmox emails never arrive: a missing /etc/aliases.db and a blocked port 25

ProxmoxPostfixEmailSelf-hosting

Run mailq on the Proxmox host. If mail is sitting there, Postfix tells you why. On mine, two problems held every email: /etc/aliases.db didn’t exist, so mail for root waited, and mail forwarded to Gmail tried to go out on port 25, which my connection doesn’t allow. newaliases fixed the first. A Proxmox notification target that sends through an SMTP relay fixed the second. No backup report had ever reached me, and I hadn’t noticed, because no email looks the same as nothing to report.

The aliases database

The host’s log had the same line over and over:

open database /etc/aliases.db: No such file or directory

It appeared more than 9,000 times in one boot. Postfix reads its aliases from the indexed file /etc/aliases.db, which newaliases builds from the text file /etc/aliases, and that file had never been built. Each time Postfix tried again to deliver the waiting mail to root, it logged the line again.

journalctl -u postfix@- --since today | grep -c aliases.db   # how often
newaliases                                                   # build /etc/aliases.db
postqueue -f                                                 # deliver what's waiting
mailq                                                        # check the queue again

The errors stopped, and the 6 messages waiting for root were delivered.

Port 25

Delivering to root wasn’t the end of it. Proxmox forwards root’s mail to the email address set on the root@pam user (proxmox-mail-forward does it), so each message then went to Postfix again, addressed to Gmail. Postfix delivers to Gmail’s mail servers directly, on port 25, and most home internet connections block outgoing port 25. The connection timed out and the message waited in the queue. Eleven were in there: every nightly backup report since 3 November and that morning’s update notice. They were stale, so I deleted them (postsuper -d ALL empties the whole queue, so look at mailq first).

The fix is not to send from the host at all. Since version 8.1, Proxmox has notification targets (the docs), and an SMTP target hands the message to a mail server you choose:

  1. Datacenter → Notifications → Add → SMTP. The server is the relay, which is a small Postfix on another VM of mine that forwards to Amazon SES. It accepts mail only from the hosts it lists, so this target has no username or password. Put a from address on a domain your relay or provider may send for, and send to root@pam.
  2. Edit default-matcher so it sends to the new target only. The built-in mail-to-root target stays, unused.
  3. Press Test, then send a real mail to root to check that forwarding still works.

Both arrived, and the relay’s log showed status=sent. If you have no relay, the SMTP target can log in to your provider directly, on port 587 with STARTTLS.

Check that email works

Proxmox doesn’t tell you when its emails fail. Run mailq after setting up a host, and again after an upgrade. An empty queue and a test message in your inbox are the only proof. Mine had never delivered one, and I found out only because I was reading the log after an upgrade.