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.


5 Responses to “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.

    May 13th, 2008 | 8:50am
  2. PeterS

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

    July 23rd, 2008 | 3:37pm
  3. David Crookes

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

    June 25th, 2011 | 2:30pm
  4. January 18th, 2009 | 4:25pm
  5. November 29th, 2010 | 7:26am

Leave a Reply