Postfix Transport Maps – Diverting Mail Traffic


If like me, you host your own mail server on your broadband then you may of come accross this problem. Some ISP’s refuse to accept mail from dynamic IP ranges, and so they should! E-mail aware worms and viruses are used all over the world to send us spam, and the majority of them are on consumer PC’s hosted on dynamic IP ranges.

Now, if you don’t have a static IP, and you want to send mail to a Gmail address your mail will be rejected. Using postfix as your MTA, you can work around this.

Most ISP’s offer an SMTP relay server, now you may not want to use this all the time, so transport maps can send only mail for gmail addresses to your smtp relay, and the rest can go direct.

Find out what your ISP’s SMTP server address is, usually smtp.yourisp.com. Create a file named transport in /etc/postfix and add the following text,

gmail.com smtp:smtp.yourisp.com:25
googlemail.com smtp:smtp.yourisp.com:25

Remember to swap “smtp.yourisp.com” for the address of your ISP’s smtp relay server.

Now we need to compile this file using the postmap command,

postmap /etc/postfix/transport

Edit /etc/postfix/main.cf and add this line at the bottom,

transport_maps = hash:/etc/postfix/transport

Restart postfix and you should find all mail addressed to @gmail.com or @googlemail.com will be redirected to your smtp relay.

7 thoughts on “Postfix Transport Maps – Diverting Mail Traffic

  1. Will V.

    Thank you for this article. It was incredibly helpful and easy to follow and adapt to my particular situation/requirements.

    Reply
  2. PeterS

    Clear and concise and more importantly, it works. Maybe instead of editing main.cf:
    postconf -e “transport_maps = hash:/etc/postfix/transport”

    Reply
  3. Pingback: /etc/postfix/transport - jak to dzia?a ? Jak poprawi? ? | hilpers

  4. Pingback: Postfix unable to find local server

  5. David Crookes

    Thank you for a useful example. I was wondering how I would specify a relay that requires authentication and SSL?

    Reply
  6. Pingback: Postfix unable to find local server - Just just easy answers

Leave a Reply

You may leave the Name and Email fields blank to post anonymously.