It has limitations as documented and if you want a more extensive solution you need something like amavis and a virus/spam filter like clamav.
There’s little point in maintaining your own file of blacklisted phrases, as spammers keep coming up with new phrases and ways to get around filter REs. My experience is that dynamic IP address blacklists block out most of the senders.
I’d already looked at the postfix manual mate, doesn’t really give much helpful info on body checks, this is about as good as the manual gets there:
EXAMPLE HEADER FILTER MAP
# These were once common in junk mail.
/^Subject: make money fast/ REJECT
/^To: friend@public\.com/ REJECT
EXAMPLE BODY FILTER MAP
# First skip over base 64 encoded text to save CPU cycles.
~^:alnum:]+/]{60,}$~ OK
# Put your own body patterns here.
The body filter example is of little or no use as an example for people wishing to add checks for particular phrases etc
I was trying it along the lines of the subject ones, trying things like /^body: /^content: etc
Already had the entries in main.cf, without those in there I wouldn’t have been getting the errors like: warning: regexp map /etc/postfix/body_checks, line 5: Invalid preceding regular expression
I’m already using amavis with spamassassin and clamav, that’s all working ok, I just wanted a look at header and body filtering to decide on it’s usefulness for cutting down even further on mails I’d like to block that get through these mechanisms on a regular basis … playing around a bit basically
I’ve worked it out myself now by deliberately sending myself some test mails from another account
Without seeing your REs, I can’t tell why they are malformed, but why the REs /^body and /^content? The body doesn’t start with either of those words. (And besides you should close the RE with another /.) The body of the email is everything after the first totally blank line. If I send out an email like this:
From: foo
To: bar
Subject: something
Hello there.
the body is just the line “Hello there”. No “body” or “content” prefixed to it.
Ecky wrote:
> Hi ken
>
> I’d already looked at the postfix manual mate, doesn’t really give much
> helpful info on body checks, this is about as good as the manual gets
> there:
>
> EXAMPLE HEADER FILTER MAP
> # These were once common in junk mail.
> /^Subject: make money fast/ REJECT
> /^To: friend@public\.com/ REJECT
>
> EXAMPLE BODY FILTER MAP
> # First skip over base 64 encoded text to save CPU cycles.
> ~^:alnum:]+/]{60,}$~ OK
>
> # Put your own body patterns here.
>
>
> The body filter example is of little or no use as an example for people
> wishing to add checks for particular phrases etc
Remember that the headerchecks deal with all content up to and including
the Subject: line.
Anything after that is dealt with by bodychecks.
So putting a rule for a subject in bodychecks won’t work.
As example, here’s my headerchecks file, although it’s almost never
activated anymore these days.