2

I have a tricky one here!

I have a dinamic list of some... 3000 email addresses that I need to filter on Postfix.

I need that if any of these addresses sends an email to (support@mydomain.com or priority@mydomain.com) the email gets redirected to low-prio@mydomain.com and put it into a folder named inbox/lowprio

I cant use just header checks, because, all mail from this users would be treated. So I am guessing that I need a header check that forwards the process to a milter that finishes it.

The concept in my mind goes like this:

Header Checks:

TO:^(.*)support@mydomain.com FILTER relay:[127.0.0.1]:10027
TO:^(.*)priority@mydomain.com FILTER relay:[127.0.0.1]:10027

In Master.cf create the filter that will catch the flow:

[127.0.0.1]:10027   inet  n       n       n       -       0       spawn
    user=nobody argv=/usr/local/mail_filter.pl

In the Perl file, get the {mail_addr} and if it is in the list, exit with a REDIRECT command. Maybe also APPEND a Header like: X-final-folder : Inbox/lowprio

This Header, would allow a Sieve to catch it and move the mail into the specified folder...

I am really struggling with this, so any help is welcome, thanks!

  • From what I can see, the following will likely be your best bet: http://www.postfix.org/header_checks.5.html The following page is where I grabbed this from: http://mattshaw.org/news/how-to-filter-mail-with-postfix-header_checks/ You might also look at the following: https://unix.stackexchange.com/questions/231232/postfix-filter-incoming-mails-based-on-mail-from-and-rcpt-to – SpartanD39 Dec 27 '18 at 02:15
  • Not really, everytime you use header checks, it will be applied to all accounts. I need the FORWARD action with 2 conditions as explained. – Iñigo InThe Cloud Dec 27 '18 at 09:48
  • this could be a good approach : https://serverfault.com/questions/688489/postfix-conditional-header-checks – Iñigo InThe Cloud Jan 03 '19 at 11:19

0 Answers0