在邮箱上运行规则?

我试图在IMAP邮箱上运行一些smartsieve规则,我当然可以为传递到该邮箱的邮件执行此操作,但是对于已经在该邮箱中的邮件,或者移动到该邮箱的邮件(通过thunderbird / outlook )规则不被处理。 是否有任何应用程序/方法在X秒/分钟的时间内在邮箱上运行规则?

按照devise,筛子从外部到达用户邮箱中处理邮件。 之后没有内置的方法来处理文件夹。

然而,从cyrus文件夹收集消息(“hotfolder”)是可能的,然后通过常规的MTA将它们重新发送到一个特殊的邮箱(“specialmailbox”),这个邮箱又有你需要的筛选规则。

为了这个目的,你可以使用这样的东西,例如,通过cron:

#!/bin/sh for msg in /var/spool/cyrus/mail/hotfolder; do sendmail speicalmailbox <$msg && rm $msg done 

“hot”文件夹中的消息将从文件系统中删除,而不将其从cyrus索引中删除,这不是最佳select。 您可以使用iprune (cyrus发行版的一部分,它会根据文件夹的年龄删除文件夹中的消息)来解决这个问题。 从文件系统中删除是必要的,所以我们不处理每个消息多次。

我希望这有帮助。

新版本的鸽舍和稻田现在有一个筛选命令。 因此,您可以编写一个脚本来扫描所有邮箱中的“INBOX.Refilter”文件夹,然后针对该文件夹运行筛选筛选器。

此脚本假定您已将邮件文件夹构build为/ var / vmail / domain / user。

 #!/bin/bash FIND=/usr/bin/find GREP=/bin/grep RM=/bin/rm SED=/bin/sed SORT=/bin/sort # BASE should point at /var/vmail/ and should have trailing slash BASE="/var/vmail/" RESORTFOLDER="INBOX.Refilter" SEARCHFILE="dovecot-uidlist" echo "" echo "Search for messages to resort under ${BASE}" echo "Started at: " `date` echo "Looking for mailboxes with ${RESORTFOLDER}" echo "" # since RHEL5/CentOS5 don't have "sort -R" option to randomize, use the following example # echo -e "2\n1\n3\n5\n4" | perl -MList::Util -e 'print List::Util::shuffle <>' DIRS=`$FIND ${BASE} -maxdepth 3 -name ${SEARCHFILE} | \ $SED -n "s:^${BASE}::p" | $SED "s:/${SEARCHFILE}$:/:" | \ perl -MList::Util -e 'print List::Util::shuffle <>'` # keep track of directories processed so far DCNT=0 for DIR in ${DIRS} do UD="${BASE}${DIR}.${RESORTFOLDER}" D=`echo "$DIR" | tr '/' ' ' | awk '{print $1}'` U=`echo "$DIR" | tr '/' ' ' | awk '{print $2}'` if [ -d "$UD/cur" ] then echo "`date` - $DIR" echo " domain: $D" echo " user: $U" FILES=`find $UD/cur/ $UD/new/ -type f -name '*' | wc -l` echo " files: $FILES" if [[ $FILES -ge 1 ]]; then echo "Run $FILES messages back through the sieve filter." # -c2 means run at best-effort, -n7 is least priority possible ionice -c2 -n7 sieve-filter -e -W -C -u "${U}@${D}" "${BASE}${DIR}.dovecot.sieve" "${RESORTFOLDER}" fi echo "" fi # the following is debug code, to stop the script after N directories #DCNT=$(($DCNT+1)) #echo "DCNT: $DCNT" #if [[ $DCNT -ge 5 ]]; then exit 0; fi done echo "" echo "Finished at:" `date` echo ""