I'm trying to configure a change of subject for incoming emails based on the "To:" address of the (virtual) email address, rather unsuccessfully. I run into two problems.

The first problem is that I can't seem to find a proper way to change the subject line based on the "To:" address. I have:

In main.cf:

header_checks= pcre:/etc/postfix/header_checks

and in header_checks:

if /^To: test@example\.com/
/^Subject: (.+)$/ REPLACE Subject: [TEST] $1

pcre is installed, but the rule doesn't seem to be applied. I tried testing it with

postmap -q "To: test@example.com" pcre:/etc/postfix/header_checks

and there is no output of that command. I am unsure whether this means that the rule did not apply or whether it doesn't show anything due to the application of a rule regarding the subject although the test is on the to header.

The second problem is that when I replace the entire file header_checks by this:

/^To: test@example\.com/ REJECT

...I can successfully test it with postmap -q (yield REJECT), but incoming mail isn't actually rejected. So I'm guessing this is another issue in addition to the one above.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.