fti*_*sem 9 linux dovecot sieve
对于我的邮件服务器,我有一个 dovecot、postfix 和筛选设置。
我的 maildir 中有数百封邮件,最近创建了一些筛选规则来对它们进行排序。不幸的是,筛选规则设计为仅适用于传入消息。因此我的问题:
如何对现有邮件目录中的邮件运行筛选?
谢谢
- - 编辑:
谢谢 larsks
通过您提供的链接,我最终使用了:
mkdir todo
mkdir done
mv cur/* todo
for i in todo/*; do
echo "Delivering message $i ..."
/usr/lib/dovecot/deliver -d mail@example.de < $i && mv $i done/
done
Run Code Online (Sandbox Code Playgroud)
这就像我的魅力一样。我可以为我创建的每个新过滤器重新运行此脚本。
没有一种简单的方法可以做到这一点,但是根据此消息,
您可以编写一个 shell 脚本来使用 Dovecot 的deliver程序重新传递消息
......所以是这样的:
produce_message_list |
while read msg; do
/usr/libexec/dovecot/deliver -d user < $msg && rm -f $msg
done
Run Code Online (Sandbox Code Playgroud)
您将不得不produce_message_list用生成要处理的消息列表的内容替换;可能find会做你需要的。
较新版本的 dovecot 和 pidgeonhole 现在带有筛选过滤器命令。因此,您可以编写一个脚本来扫描所有邮箱中的“INBOX.Refilter”文件夹,然后对该文件夹运行筛选过滤器。
此脚本假定您已将邮件文件夹结构化为 /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 ""
Run Code Online (Sandbox Code Playgroud)
小智 5
我也搜索了很多 - 很少有记录。
同时有一个命令
sieve-filter
Run Code Online (Sandbox Code Playgroud)
为此,可以在此博客https://mebsd.com/configure-freebsd-servers/dovecot-pigeonhole-sieve-filter-refilter-delivered-email.html上找到操作方法
| 归档时间: |
|
| 查看次数: |
5278 次 |
| 最近记录: |