zlib, mdbox and spam filtering scripts
sven at svenhartge.de
Mon Dec 22 22:45:20 UTC 2014
Philon <bytesplit at gmail.com> wrote:
> I also looked into Sven’s advice (Danke!) about doveadm fetch. I just
> came across this script here:
> https://git.mnt-tech.fr/admintools.git/raw/master/blacklist.sh. It
> does much more than just fetch, but for me it was a good reference for
> retrival of mails using doveadm.
My code for my personal "salearn" script looks like this:
| tempdir=`mktemp -d`
| doveadm search mailbox SPAM | while read guid uid;
| tempfile=`mktemp --tmpdir=$tempdir`
| echo -n "$uid "
| doveadm fetch text mailbox-guid $guid uid $uid | tail -n +2 | head -n -1 > $tempfile
| sa-learn --spam --no-sync --progress $tempdir
| sa-learn --sync
| rm -r $tempdir
- The dance with "| tail -n +2 | head -n -1" is to remove the leading
"text:" line and the ^L (page feed) at the end doveadm inserts. (I
really would like to have an option to fetch the raw source of the
mail without doveadm adding, removing or reformatting anything.)
- I don't use "-u '*'" here since this script runs as my user only
directly on the server where the mails are stored. If you want to
learn mails from multiple users you will of course need to iterate
over all of them, just as the example script from mnt-tech.fr does.
Sigmentation fault. Core dumped.
More information about the dovecot