Question
How to apply sieve filters to existing email?
Answer
In a mail import scenario, you may not be able to retrieve folder configuration. It's possible to organize existing email into folders and other actions using Dovecot "sieve-filter" and using Roundcubes interface.
https://pigeonhole.dovecot.org/doc/man1/sieve-filter.1.html
Example:
You have mail in a folder called Refilter you want to organize into other folders based on subject, etc.
# sieve-filter -v -D -e -W -u "user@domain.com" /var/qmail/mailnames/domain.com/user/sieve/roundcube.sieve INBOX.Refilter
This command manually applies a Sieve filter script to a specific mailbox folder (INBOX.Refilter) for a given email user.
-v: Enables verbose output, providing more detailed information during execution.
-D: Enables debug output, useful for troubleshooting script behavior.
-e: Turns on execution mode. By default, the sieve-filter command runs in simulation mode in which it changes nothing, meaning that no mailbox is altered in any way and no actions are performed. It only prints what would be done. Using this option, the sieve-filter command becomes active and performs the requested actions.
-W: Enables write access to the source-mailbox. This allows (re)moving the messages from the source-mailbox, changing their contents, and changing the assigned IMAP flags and keywords.
-u "user@domain.com": Specifies the email account to which the filter should be applied.
/var/qmail/mailnames/domain.com/user/sieve/roundcube.sieve: Path to the Sieve script file, typically generated by Roundcube's filter interface.
INBOX.Refilter: The source mailbox
Check correct mailbox name with:
# doveadm mailbox list -u user@domain.com
Comments
Please sign in to leave a comment.