1

With Postfix it is possible with an entry in main.cf (virtual_alias_maps = hash:/etc/postfix/virtual) and an additional file (here /etc/postfix/virtual) to forward e-mails depending on the recipient.

My question is, how can e-mails be forwarded to a specific address depending on the sender and recipient? There are no local users/e-mail recipients on the server.

An example: E-mails from alice@customer42.com to bob@example.com should be forwarded to office@example.com. Can someone help me with this question?

  • A milter could do this, with the downside of the complexity of a milter (also what happens when the message is to multiple folks?) – thrig Sep 20 '17 at 20:22
  • In this case, the email should be forwarded to office@example.com and all other recipients, but not to bob@example.com. – Cyrus Sep 20 '17 at 20:31
  • Sieve can do this. I assume there's a Sieve plug-in for Postfix delivery – roaima Sep 24 '17 at 20:08
  • 1
    You could consider using procmail, perhaps in your ~/.forward – Basile Starynkevitch Sep 25 '17 at 7:23
  • @BasileStarynkevitch: Since it is only about one recipient (bob@example.com), that would be a possibility. – Cyrus Sep 25 '17 at 7:32
2
+100

Postfix by itself CANNOT.

http://www.postfix.org/BUILTIN_FILTER_README.html

Header/body checks cannot depend on the recipient of a message.

One message can have multiple recipients, and all recipients of a 
message receive the same treatment. Workarounds have been proposed that 
involve selectively deferring some recipients of multi-recipient mail, 
but that results in poor SMTP performance and does not work for non-
SMTP mail.

Some sources of mail send the headers and content ahead of the 
recipient information. It would be inefficient to buffer up an entire 
message before deciding if it needs to be filtered, and it would be 
clumsy to filter mail and to buffer up all the actions until it is 
known whether those actions need to be executed.

You need a milter.

  • Thanks for this information. I can see it's getting more complicated. – Cyrus Sep 25 '17 at 7:27

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.