How can I configure Postfix to ignore relayhost when forwarding mail?

I currently use the relayhost to send all outgoing email via an external SMTP service :

# /etc/postfix/main.cf
relayhost = [smtp.mandrillapp.com]

A couple of my domains are configured to send via an alternative SMTP service :

# /etc/postfix/relayhost_maps
@domain1            [email-smtp.us-east-1.amazonaws.com]
@domain2            [email-smtp.us-east-1.amazonaws.com]

However, a few of my customers have their incoming email forwarded to other accounts. I don't want to be sending forwarded email via my external SMTP service, instead I want it relayed directly by localhost.

For example, my machine accepts email for 'user@domain3.com', which the client has configured to be forwarded to 'other@hotmail.com'. What I'm looking for is a way to have any emails forwarded to 'other@hotmail.com' relayed directly by my server - and not relayed by my external SMTP service.

I think transport maps are close to what I need, and I have found lots of information on how to route to an external SMTP with transport mapping, but I can't figure how to relay from localhost only when forwarding mail.

I thought I had a solution here:

How can I configure Postfix to ignore relayhost for some domains?

... but when I tried it, I sent an email to myself and received it 2,500 times in some sort of loop between my machine and my SMTP gateway, and had to quickly stop Postfix!

So, basically I want to relay forwarded messages from localhost, and non-forwarded messages via various SMTP services.


Have a


line in main.cf, then add to /etc/postfix/transport :

other@hotmail.com smtp:

run postmap /etc/postfix/transport and reload postfix if you changed main.cf .

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.