From derhil / kromonos, 1 Year ago, written in Bash.
Embed
  1. #!/bin/bash
  2.  
  3. SALEARN=/usr/bin/sa-learn
  4.  
  5. echo "Spam: $( ${SALEARN} --username=spamd --no-sync --spam /var/customers/mail/*/*/.Junk/cur/* )" | /usr/bin/systemd-cat -t "spamassassin"
  6. echo "Ham:  $( ${SALEARN} --username=spamd --no-sync --ham /var/customers/mail/*/*/.Sent/cur/* )" | /usr/bin/systemd-cat -t "spamassassin"
  7. echo "Syncing ... $( ${SALEARN} --username=spamd --sync )" | /usr/bin/systemd-cat -t "spamassassin"
  8.  
  9. rm -f /var/customers/mail/*/*/.Junk/cur/* &> /dev/null
  10.  
  11. exitcode=$?
  12.  
  13. if [ $exitcode = 0 ]; then
  14.     echo "Spam/Ham successfully learned." | /usr/bin/systemd-cat -t "spamassassin"
  15. else
  16.     echo "Error! (train-spamfilter)"
  17. fi
  18.