Postfix: Forward undeliverable mail to another server for same domain

emailmail-forwardingpostfix

I recently did some work for somebody, and as a side, he asked me if it was possible to have postfix forward mail from one server to another for the same domain. For example, let's say his domain is example.com and he has an MX record that points to linux.example.com. He has some mailboxes hosted on linux.example.com and other ones hosted on windows.example.com. He wants any undeliverable mail that reaches linux.example.com to be forwarded to windows.example.com, still @example.com, of course.

Example scenario:

  • linux.example.com hosts bob@example.com
  • windows.example.com hosts tom@example.com
  • MX records point to linux.example.com
  • A user sends an e-mail to tom@example.com. Postfix (on the GNU/Linux machine) sees that it doesn't have a user named tom and registers an undeliverable. Rather than responding to the requestor with an undeliverable message, the user wants the data to be forwarded on to windows.example.com.

He is willing to create a record for every e-mail that resides on the Windows machine if necessary, but he would prefer that it always just forward undeliverables to the Windows machine so that he doesn't have to create a record every time he makes a new mailbox on the Windows server.

Best Answer

If I understood your problem correctly I think you can do it configuring luser_relay on linux.example.com.

Set in main.cf

luser_relay = = $user@windows.example.com

http://www.postfix.org/postconf.5.html#luser_relay

If you don't have an MX record for domain windows.example.com and you don't want to create one you can use transport on linux.example.com for it to know where to deliver emails for *@windows.example.com. By default in postfix you have included $myhostname in $mydestination so windows.example.com will accept it.