Peter's Blog

Redefining the Impossible

Postfix relaying internal email


Latest MTA to use under linux is postfix as this appears to be a ubuntu standard. I fancy trying something a bit lighter than exim and there doesn't appear to be a debian package for qmail and I can't be bothered to build it.

As this mail server is running on my little intranet box at work I need it to forward internal email to the company internal email server. If I email pcw@mycompany.com from the box the email gets bounced with "Name or service not known" because the DNS server configuration is screwed up and mycompany.com resolves to the internal file server, not the mail server.

Anyway, I worked out the postfix incantation to do this and it's not a pretty thing, it doesn't bode well for postfix ease of use:

  • Create/edit a file called /etc/postfix/transport
  • Add relay instruction along the lines of:
    mycompany.com        smtp:192.168.0.5
    
    or wherever you want to relay to.
  • execute the command
    sudo postmap /etc/postfix/transport
    
  • edit /etc/postfix/main.cf and add the following:
    relay_domains = $mydestination, mycompany.com
    transport_maps = hash:/etc/postfix/transport
    
  • execute the command
    sudo postfix reload
    
    to reload the configurations (or /etc/init.d/postfix restart).

This worked for me, from my server box I can email myself on internal email allowing me to get messages from servers etc.


Filed under: email linux postfix ubuntu

1 Comment

Steve Says:

over 2 years ago

I know this is an old post but I just found it handy. I couldn't get mail to go smoothly to external and internal addresses but this is the answer (not an obvious one either). Thanks so much.

Sorry but comments on this post are now closed.