How to REJECT email using SpamAssassin
Is it possible to reject emails, like it is done in Postfix using header_checks, using SpamAssassin? Normally, the SpamAssassin only adds the spam flags and by default adds the word SPAM in the subject of the emails. But if SpamAssassin classifies a email as SPAM is it possible to tell postfix to reject that email instead of going to inbox of user account? Thank you
Solution 1:
In SMTP session rejects using milters
You can make postfix use spamassassin to reject messages in SMTP session.
It makes sending host responsible for sending bounce notification back to sender.
Sendmail, Postfix and a few more MTA/SMRP servers support milters.
Postfix: http://www.postfix.org/MILTER_README.html
There are a few milters supporting spamassassin to choose from:
https://cwiki.apache.org/confluence/display/spamassassin/IntegratedInMta
Classic approach is to
- reject "most likely spam" in SMTP session (e.g. spam score > 10)
- mark "may be spam messages" (custom header or modified
Subject:
)
Warnings
- spamassassin tests in network mode may take a few seconds which is unacceptable for many MTA/SMTP server. Local mode is faster but less accurate.
- It MAY hit your server performance especially under high+ load.
- Small minority of ham sending servers is VERY "impatient"
- Bayes test are crucial for very good spamassassin accuracy but they are harder to train when filtering for multiple recipients
Solution 2:
man spamass-milter
and note the -r
flag. Specify a high spam score value after the -r
and spamass-milter
will reject messages that score at that level or higher.
This is with sendmail
, but I suspect your syntax will be similar:
spamass_milter_flags="-r 25 -R 'Message content rejected' -f -p /var/run/spamass-milter.sock -i 127.0.0.1"