Skip to content

Sending mail from a NATed host with Postfix

When sending mail from a host behind NAT, you will run into trouble when the “From” says “root@host.localdomain”, because receiving servers will refuse that domain.

I’m not quite sure why, but setting myorigin used to be enough. Now I need to do this in

# For when you have a host behind NAT that is refusing to 
# use as specified as origin.
# You can test with: 
# postmap -q "fubar@hostname.somelocaldomain" regexp:/etc/postfix/sender_canonical
sender_canonical_maps = regexp:/etc/postfix/sender_canonical

And in sender_canonical:

/^(.*@)host.*$/     ${1}

Or more generic:

/^(.*@.*\.)company$/     ${1}

And as usual, I use a relay host.

No Comments ( Add comment / trackback )