Для тех, кто может наткнуться на этот пост с похожим вопросом, ниже, как я решил эту проблему. Я перешел в fetchmail из offlineimap, чтобы поместить сообщения в отдельный каталог, и я добавил приведенный ниже сценарий к cron.
#!/bin/bash
#Mail directories. Do not include the trailing /.
NEWMAIL="/home/mike/.mailqueue"
INBOX="/mnt/filestore/mail/mike/INBOX/new"
JUNK="/mnt/filestore/mail/mike/.Junk/new"
#fetch new messages
fetchmail
#move any messages in new to cur
echo "Moving messages in /new to /cur"
mv $NEWMAIL/new/* $NEWMAIL/cur/
#check if directory contains files
if [ "$(ls -A $NEWMAIL/cur/)" ] ; then
#move out files that already have spamassassin headers to the INBOX and Junk folders
echo "Moving pre-processed files."
grep -lIZ ^X-Spam-Status\:\ Yes \
$NEWMAIL/cur/* |
xargs -I '{}' -0 mv '{}' $JUNK/
grep -lIZ ^X-Spam-Status\:\ No \
$NEWMAIL/cur/* |
xargs -I '{}' -0 mv '{}' $INBOX/
#run spamassassin on each remainining file and append .processed to the filename
for file in $NEWMAIL/cur/*
do
echo "Processing $file"
spamassassin $file > $file.processed
done
#move the processed files to the INBOX and Junk folders
echo "Moving processed files."
grep -lIZ ^X-Spam-Status\:\ Yes \
$NEWMAIL/cur/* |
xargs -I '{}' -0 mv '{}' $JUNK/
grep -lIZ ^X-Spam-Status\:\ No \
$NEWMAIL/cur/* |
xargs -I '{}' -0 mv '{}' $INBOX/
#delete the remaining files
echo "Deleting the remaining files."
rm -Rf $NEWMAIL/cur/*
#no files in directory
else
echo "Nothing to do."
fi