Hello, I am looking for a command-line utility to automatically purge one Maildir folder. I want to periodically run sa-learn from cron, and after the spam learning folder has been added to the Bayes database, its contents should be deleted. I've searched a bit, but only found a few old utilities or some telnet+expect scripts, which both didn't look too reliable. Is there any command-line utility to delete all contents of a Maildir folder, or is there any other solution? Thanks, Florian
Florian Effenberger wrote:> Hello, > > I am looking for a command-line utility to automatically purge one > Maildir folder. I want to periodically run sa-learn from cron, and > after the spam learning folder has been added to the Bayes database, > its contents should be deleted. I've searched a bit, but only found a > few old utilities or some telnet+expect scripts, which both didn't > look too reliable. > > Is there any command-line utility to delete all contents of a Maildir > folder, or is there any other solution? > > Thanks, > Florian >I would write a script that cron executes, and have the script do the sa-learn, then delete the file. I run qmail-toaster, which uses vpopmail for virtual domains/accounts. My maildirs for learning ham/spam are shared, and are named sa-learn/Ham and sa-learn/Spam. Here's the script that I run in cron.daily to execute sa-learn: #!/bin/sh ##################################################################### # learn and remove spam and ham in shared folders ##################################################################### # shubes 3/26/08 - created ##################################################################### learndir="/home/vpopmail/domains/shubes.net/sa-learn" hambox=.Ham spambox=.Spam do_the_learning(){ learnas=$1 maildir=$2 shopt -s extglob for spamfile in `find $maildir/+(cur|new)/* 2>/dev/null`; do sudo -u vpopmail -H sa-learn --$learnas $spamfile rc=$? if [ $? != "0" ]; then echo "sa-learn failed, rc=$rc, spamfile=$spamfile" exit $rc fi rm $spamfile done } do_the_learning ham "$learndir/$hambox" do_the_learning spam "$learndir/$spambox" exit 0 # end of script HTH. -- -Eric 'shubes'
On Tue, 2010-05-25 at 21:29 +0200, Florian Effenberger wrote:> Hello, > > I am looking for a command-line utility to automatically purge one > Maildir folder.How about just: rm -f /path/to/Maildir/.spam-learn/* With v2.0 you can also do: doveadm expunge -u username mailbox spam-learn all
Florian Effenberger <floeff at gmail.com> wrote:> I am looking for a command-line utility to automatically purge one > Maildir folder. I want to periodically run sa-learn from cron, and > after the spam learning folder has been added to the Bayes database, > its contents should be deleted. I've searched a bit, but only found a > few old utilities or some telnet+expect scripts, which both didn't > look too reliable. > > Is there any command-line utility to delete all contents of a Maildir > folder, or is there any other solution?Have you considered fetching from dovecot (maildir) to mbox file and learning from mbox file? a) fetchmail CAN use .../dovecot/imap wrapper script in "plugin" option to read maildir directly [set environment variable MAIL to maildir:~/Maildir in the wrapper] b) fetchmail CAN use procmail in "mda" option to deliver directly to mbox -- [pl>en: Andrew] Andrzej Adam Filip : anfi at onet.eu I am a friend of the working man, and I would rather be his friend than be one. -- Clarence Darrow