Ubuntu 16.04下SpamAssassin未过滤得分超阈值垃圾邮件求助
probably-spam Folder Let's break down the issues and fixes step by step:
First, Clarify the Obvious from Your Provided Header
The email header you shared shows X-Spam-Status: No, score=-5.0 required=3.0 — this mail is not spam (score is way below your 3.0 threshold), so it’s expected that it wouldn’t get moved to probably-spam. If you’re seeing other emails with scores above 3.0 that aren’t being filtered, focus on those for debugging.
Step 1: Verify Which Emails Actually Meet the Spam Threshold
First, confirm which messages in your mbox have scores exceeding your required value. Run this command to extract all spam status headers:
formail -s grep 'X-Spam-Status' < mbox
This will list every email’s score and status. Note any entries where score=[number] is ≥3.0 but still marked as No — those are the ones you need to investigate further.
Step 2: Check Your Procmail Rule Order & Configuration
Procmail processes rules top-to-bottom, so your SpamAssassin processing rule must come before your spam filtering rule. Here’s a correct example of what your procmail.rc should include:
# First, pass mail through SpamAssassin (spamc is the lightweight client) :0fw: spamassassin.lock * < 256000 # Skip large mails to save resources (adjust as needed) | spamc # Then, filter spam to probably-spam folder :0: * ^X-Spam-Status: Yes probably-spam
If your filtering rule comes before the SpamAssassin rule, Procmail will check the (unprocessed) email headers before SpamAssassin adds the X-Spam-Status tag — so it’ll never match.
Step 3: Test SpamAssassin’s Functionality Directly
Is SpamAssassin actually scoring emails correctly? Grab a copy of a problematic email (save it to a file like test-spam.txt) and run:
cat test-spam.txt | spamc -v
Look at the output’s X-Spam-Status line. If the score here doesn’t match what you expect, check your local.cf configuration:
grep 'required' /etc/spamassassin/local.cf
Ensure the required value is indeed set to 3.0. Also, update your SpamAssassin rules (critical for accurate scoring on Ubuntu 16.04):
sudo sa-update
Step 4: Enable Procmail Logging to Debug Execution
Add these lines to the top of your procmail.rc to see exactly what’s happening during processing:
LOGFILE=$HOME/procmail.log VERBOSE=yes
Re-run your original command (formail -s procmail ~/procmail.rc < mbox), then check procmail.log. Look for lines like:
Match on "^X-Spam-Status: Yes"(confirms the rule triggered)Delivering to probably-spam(confirms the mail was moved)
If you don’t see these, your rule isn’t matching — double-check the regex or rule order.
Step 5: Confirm Folder Permissions
Make sure your probably-spam folder exists and has the right permissions for your user:
ls -ld ~/probably-spam
If it doesn’t exist, create it:
mkdir ~/probably-spam chmod 700 ~/probably-spam
Procmail can’t move mail to a folder it can’t write to.
内容的提问来源于stack exchange,提问作者ComfortMoose

