TL;DR: I'm trying to force postfix to route mail sent from local user to another local user to be routed to another server (relayhost). This should not apply to incoming mail from external to local.

I'm planning a mail server stack migration (new imap and new smtp on new hardware). For a limited time, some users will be routed to the current server while others will me gradually migrated to the new mail server.

The current server will be the one that does all the routing (also the one registered in DNS as MX). When an incoming mail is coming, the mail will be forwarded or not on the new server based on the recipient mail address. This is working fine.

I'm having problem with local outgoing email routing (migrated colleague trying to send mail to non-migrated colleague). If I do nothing, a migrated colleague sending an email to a non-migrated user would seen his mail to the future inbox of non-migrated user. So the non-migrated user would not receive this mail until I migrated him.

I would like new Postfix to route outgoing emails to relayhost even if the mail is "local". The relayhost is the server listed in DNS as MX, so the routing would be the same as the one I use for incoming mail.

I played with the transport_maps, but this cause incoming mail to loop between the old and the new server. This is because transport_maps apply for all emails (including incoming from external), not just the one local user send. The routing should only apply to outgoing mail from local users, not for all mail.


transport_maps = hash:/etc/postfix/transport


domain.tld          smtp:[old-smtp.domain.tld]

1 Answer 1


Sender dependent relayhost maps should do the job.

See the Postfix documentation

  • Doesn't work. Postfix still route the outgoing mail directly to dovecot-lmtp without going to my old-smtp. Added sender_dependent_relayhost_maps = hash:/etc/postfix/relayhost to my main.cf and added @domain.tld smtp:[old-smtp.domain.tld] in my relayhost file.
    – Francis
    Feb 19, 2019 at 14:46

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.