2

I have a Maildir with about 50k emails, about 42k of which are spam (the result of leaving my domain and email up and not using it for 2 years).

I have the following script to try and filter out spam:

#!/bin/sh
for email in "$@"; do
  if ! spamassassin -e < "$email" > /dev/null 2>&1; then
    mv "$email" /tmp/spam
  fi
done

But this is taking forever!

The device I am only able to do this on is limited, it's a NAS with an arm processor...but still!

Is there possibly any faster way to do this? At the moment, workingon a subdir with 1000 files, it's been going for almost 12 hours and found 36 spam messages...

1
  • Where's the bottleneck?
    – womble
    Oct 19, 2017 at 4:25

1 Answer 1

3

You may start spamd daemon in "local tests only" mode and test messages using spamc command. It should eliminate huge part of spamassassin initialization e.g. parsing perl and configuration files.

Running network tests for huge number old messages (up to two years old) is not cost/time effective IMHO.

AFAIR on my old laptop processing one message in "local only mode" takes spamc around 0.3s (three messages per second or 10_000 messages per hour), processing one message in "network mode" take usually 5-7s over mobile broadband connection. It would be a good idea to run a few network tests in parrallel during mass checks.

You will find a summary of performance related topics in the spamasassin manual.


#!/bin/sh
for email in "$@"; do
  # SCORE - "12.7/5.0" on success OR "0/0" on error
  SCORE=`spamc -c < "$email" > /dev/null 2>&1`
  # EXIT - 1 on spam detection, 0 on not-spam or error 
  EXIT=$?
  if [ "$EXIT" = "1" ] ; then
    mv "$email" /tmp/spam
  fi
done
2
  • Thank you very much, that sounds like a huge improvement! I am not familiar with spamassasin at all, and have no idea how to do that. Would you be willing to provide some mroe steps or a link? If not, no issue, I will figure it out, thank you :) Oct 14, 2017 at 16:16
  • Which OS (Linux distribution) do you run on th NAS? spamd configuration & startup depends on it. BTW I sometimes start "personal spamd" on my non privileged user account and access it over unix socket.
    – AnFi
    Oct 16, 2017 at 11:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .