File: //proc/self/root/usr/libexec/dovecot/sieve/report-ham.sieve
require ["copy", "imapsieve", "fileinto", "environment", "vnd.dovecot.execute", "variables", "regex", "editheader"];
if environment :matches "imap.mailbox" "*" {
set "mailbox" "${1}";
}
if string "${mailbox}" "INBOX.Trash" {
stop;
}
if environment :matches "imap.user" "*" {
set "username" "${1}";
}
if header :regex "Subject"
"^\\[SPAM\\] \\([0-9\\.]+\\) (.*)$" {
addheader "Subject" "${1}";
}
if execute :pipe "learn-ham.sh" [ "${email}" ] {
fileinto "${mailbox}";
stop;
}