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 main.cf:

# For when you have a host behind NAT that is refusing to 
# use hostname.realdomain.net 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_canocical:

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

And as usual, I use a relay host.


    No Comments ( Add comment / trackback )

    Post a comment

    (required)
    (required)

    Your email is never published nor shared.

    (optional)
    Allowed HTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>