Redirect specific e-mail address sent to a user, to another user

postfixredirect

I need to redirect e-mail within our MTA when the two following criteria are both true:

When an e-mail is:

  • Sent from: user@isp.com
  • Addressesd to: user@ourcompany.com

Result: redirect e-mail to user2@ourcompany.com.

I don't want to catch *@isp.com and redirect, and I don't want to redirect all e-mail addressed to user@ourcompany.com but only redirect when user@isp.com sends user@ourcompany.com an e-mail.

How do I achieve this within Postfix's configuration. And if it's not possible within Postfix, what may be the best solution?

Best Answer

You can use PCRE In /etc/postfix/main.cf:

header_checks = pcre:/etc/postfix/headers_check

/etc/postfix/headers_check:

/To:.*@(?!mail.domain.com) && From:.*@?!extdomain.com/ REDIRECT mailbox@mail.other.domain.com

PCRE works with perl regular extentions, and you can specify any conditions.

Related Topic