Hi There, I want create a filter that will check incoming email and replace the subject. I found on net this filter: if /^To: test@example\.com/ /^Subject: (.+)$/ REPLACE Subject: [TEST] $1 endif But when I add this in ISPcondig Content filter nothing happen. (I replaced test@example\.com with my own email) Source code of the email is little different To: Firstname Lastname <[email protected]> so tried to change it to: if /^To: Firstname Lastename example@mydomain\.com/ /^Subject: (.+)$/ REPLACE Subject: [TEST] $1 endif Didn't work also. Can someone help me to crate the right filter to add in ISPcondig? Cheers, Peter
I've never tried this before, but in a quick look I don't see any way to enter the if/endif conditional in the ui, how is it you are accomplishing that? I would expect this has to be done manually, directly in postfix config, and not via the ISPConfig ui, but maybe I'm missing something.
Hey, coincidentally this thread just came through postfix-users which explains why what you are wanting to do can't work: https://marc.info/?l=postfix-users&m=164243590917033&w=2
What might work is to change the subject via sieve in the receiving inbox instead: https://superuser.com/questions/1502588/how-to-change-a-messages-subject-in-a-sieve-rule
This is for now what I have found. Its do a check but always give the first IF and not the second one. Code: root@mail:/home/poudenes# cat test.eml From: Nobody <[email protected]> Mime-Version: 1.0 To: <[email protected]> Subject: TESSUBJECT This is a test message header_checks files have this Code: if !/^To: [email protected]/i /^Subject: (.+)$/i REPLACE Subject: (test1) [$1] endif if !/^To: [email protected]/i /^Subject: (.+)$/i REPLACE Subject: (test2) [$1] endif Code: root@mail:/home/poudenes# postmap -vhmq - regexp:/etc/postfix/header_checks < test.eml postmap: name_mask: all postmap: inet_addr_local: configured 2 IPv4 addresses postmap: inet_addr_local: configured 2 IPv6 addresses postmap: dict_open: regexp:/etc/postfix/header_checks postmap: dict_regexp_lookup: /etc/postfix/header_checks: From: Nobody <[email protected]> postmap: dict_regexp_lookup: /etc/postfix/header_checks: Mime-Version: 1.0 postmap: dict_regexp_lookup: /etc/postfix/header_checks: To: <[email protected]> postmap: dict_regexp_lookup: /etc/postfix/header_checks: Subject: Subject: TESSUBJECT REPLACE Subject: (test1) [TESSUBJECT]
That sounds correct. As the thread I linked to above explains, header checks work on one header at a time; for any message that comes through, the Subject header will not match your regex that starts with "To:", so the transformation on the subject line will be performed. What you are trying to do can't work. @till posted above one possible solution, ie. perform the rewriting in sieve.
thanks for the info. Changing subject in sieve is not working. I have some email addresses that are aliases and goes to a other. All mails that comes in for the alias I want change the subject. So I can see in the mailbox in subject what used receiving email address was used. That was the whole idea. But I think im stuck and have to accept that it won't work what I want