I'm running postfix + dovecot, and all IMAP messages are in /var/vmail/DOMAIN/USER
. I'd like to make a cron script that will look for messages for all users in a folder called 'False Positives,' sa-learn
them as ham, and then move them into the inbox.
The question here is, is it safe to just mv
one of these message files around? Or must it be done through some "official" means so the IMAP server is aware of the move?
Dovecot detects mailbox changes and rebuilds indexes automatically. Instead of 'mv' however, you could use dovecot's doveadm command and save the unnecessary index rebuilds.
Something like this should work:
Explanation:
doveadm search -A mailbox 'False Positives'
-> returns user/guid/uid of all messages in a "False Positives" Folderdoveadm fetch -u $user text mailbox-guid $guid uid $uid | sa-learn --ham
-> prints out the full message (header & body) and pipes it to sa-learndoveadm move -u $user INBOX mailbox-guid $guid uid $uid
-> moves the message to INBOX