Blog · Deliverability

Why Postfix masquerade_domains Doesn't Apply to Mail From Other Systems

If you've set masquerade_domains = example.com in your Postfix config and expected every sender address to be rewritten to smtp@example.com, you may have noticed something confusing: mail sent directly from the Postfix server gets rewritten correctly, but mail relayed from other systems on your network doesn't.

That's not a bug. That's how masquerade_domains is designed to work.

The short version: masquerade_domains only acts on mail submitted by local programs running on the Postfix server itself - things like cron jobs, PHP scripts, or MTA services running on the same host. Mail that arrives via SMTP from another machine on your network is outside its scope. For that, you need sender_canonical_maps.