Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Have a

transport_maps=hash:/etc/postfix/transport

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 .

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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