This document describes, in a fully reproducible and platform‑correct way, how the sender of locally generated emails (e.g. Proxmox alerts) is rewritten to a clean, consistent identity such as:
Proxmox <alerts@example.com>
with delivery via Gmail as smart relay (smtp.gmail.com:587).
The solution is native Postfix, requires no milters, no OpenDKIM, and is fully supported on Debian 12 / Proxmox VE.
- Proxmox sends alerts as
root@<hostname> - Mail clients (Gmail) show root as sender name
- SPF / DKIM / DMARC must remain valid
- The solution must be upgrade‑safe and simple
- Rewrite the visible sender to a fixed, human‑friendly identity
- Normalize the SMTP envelope sender
- Relay mail securely via Gmail
- Avoid unsupported or deprecated tooling
The following approaches were explicitly tested and rejected:
- Debian/Proxmox OpenDKIM builds do not reliably support header rewriting
conf.dincludes fail- Service startup is inconsistent
- Not available in Debian 12 (bookworm)
- Not present in
main,contrib, or Proxmox repositories
- Unnecessary complexity
- Harder to maintain
The final working solution consists of two clearly separated parts:
- Mail relay via Gmail (SMTP + authentication)
- Sender normalization using native Postfix mechanisms
Both parts are required for a correct and reliable result.
apt install postfix libsasl2-modules ca-certificatespostfix– Mail Transfer Agentlibsasl2-modules– SASL authentication supportca-certificates– TLS certificate validation
apt install postfix-pcreThis package enables the pcre: dictionary type in Postfix.
Without it, Postfix logs errors such as:
unsupported dictionary type: pcre
The system hostname must be correct and consistent, otherwise Postfix will embed legacy hostnames in headers.
Executed:
hostnamectl set-hostname proxmox.example.localVerified in:
/etc/hostname/etc/hosts
This prevents old or unintended hostnames from appearing in generated mail.
The Proxmox host does not deliver mail directly to the internet. All outbound mail is relayed via Gmail.
relayhost = [smtp.gmail.com]:587
smtp_use_tls = yes
smtp_tls_security_level = encrypt
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous[smtp.gmail.com]:587 alerts@example.com:APP_PASSWORD_OR_OAUTH_TOKEN
Notes:
- This is not the account password
- Use either a Gmail App Password or an OAuth2 / API token
Then:
postmap /etc/postfix/sasl_passwd
chmod 600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db/^From:\s*root\b.*$/ REPLACE From: "Proxmox" <alerts@example.com>
This rewrites the visible From header (display name + address).
/^root(@.*)?$/ alerts@example.comThis rewrites the SMTP envelope sender (MAIL FROM) so that root@hostname is never exposed at SMTP level.
# Allow rewriting for locally generated mail
local_header_rewrite_clients = static:all
# Header rewriting
header_checks = pcre:/etc/postfix/header_rewrite.pcre
smtp_header_checks = pcre:/etc/postfix/header_rewrite.pcre
# Envelope sender rewriting
sender_canonical_maps = regexp:/etc/postfix/sender_canonicalpostmap /etc/postfix/sasl_passwd
systemctl restart postfixVerification:
postconf -m | grep pcreExpected output:
pcre
echo "rewrite test" | mail -s "Proxmox alert test" admin@example.comExpected result in Gmail:
From: Proxmox <alerts@example.com>
No:
- deferred mail
rootas sender- SMTP errors
The following components were deliberately removed:
apt purge -y opendkim opendkim-tools
rm -rf /etc/opendkim
rm -rf /run/opendkimReason:
- Not supported for this use case on Debian 12
- Avoids future confusion
This setup provides:
- Native Postfix solution
- Gmail relay with secure authentication
- Clean sender identity for Proxmox alerts
- Full compatibility with Debian 12 / Proxmox VE
- Minimal moving parts
The configuration is upgrade‑safe, auditable, and production‑ready.
End of document.