require [ "copy", "environment", "imapsieve", "variables", "vnd.dovecot.pipe" ];

if environment :matches "imap.mailbox" "*" { set "mailbox" "${1}"; }
if string "${mailbox}" "Trash" { stop; }
if string "${mailbox}" "Corbeille" { stop; }

if environment :matches "imap.user" "*" { set "username" "${1}"; }

pipe :copy :try "learn-ham.sh" [ "${username}" ];