Postfix discard not working properly

Jayman8543 asked:

I have set up some bad phrases to look for inside the body_checks file. I’m not sure if I should post them here b/c of the nature of the words. An example of how I have it structured is like this:

/badword/    DISCARD
/anotherbadword/    DISCARD
/yetanotherbadword/    DISCARD

My version is:

mail_version = 2.10.1

I am seeing this in my maillog although none of these words match anything from my body_checks file.

discard: body <p style="margin-top: 0; margin-bottom: 10px;">We understand that your time is valuable which is why we would love to reward you with 50 Reward Points for each verified review that you submit. It only from local; from=<[email protected]>

This only seems to happen when the email contains this line of string but again none of these words are inside my body_checks file. Anyone else seen this happen before? If it is ok for me to post a link to my body_checks file plz let me know. I just didn’t want to violate any policies here due to the nature of the words.

Update:

Ok, I finally figured out which phrase was the issue by searching the entire email and not just what was shown in the CLI maillog but I’m not sure why it was triggered.

Inside my email I have the word click and in my body_checks file I have the same word but without the the leading “c”.

Is there a way to do an exact match to prevent this going forward?

My answer:


If you’re trying to match actual words, instead of just random bits of text that might appear within a word, you should include word boundaries in your regular expression.

For example:

/man/ DISCARD

This will match both man and humans.

But use the word boundary to indicate that you want to match only a complete word.

/\bman\b/ DISCARD

Now this will match man, but not humans.


View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.