1 require [ "copy", "environment", "imap4flags", "imapsieve", "variables", "vnd.dovecot.pipe" ];
3 if environment :is "imap.changedflags" "Junk" {
4 if environment :matches "imap.user" "*" { set "username" "${1}"; }
5 if hasflag :is "Junk" {
6 pipe :copy :try "learn-spam.sh" [ "${username}" ];
7 } elsif not hasflag :is "Junk" {
8 pipe :copy :try "learn-ham.sh" [ "${username}" ];