I'm trying to get blow Sieve filter to work
require ["fileinto", "imap4flags", "mailbox", "body", "envelope", "vnd.dovecot.pipe", "variables", "vnd.dovecot.execute"];
if envelope :matches "To" "*@*" {
set "recipient" "${0}";
set "user" "${1}";
set "recip_domain" "${2}";
}
if envelope :matches "From" "*" {
set "sender" "${0}";
}
#Check if recipient is valid user
if execute :output "valid_user" "user-verification" "${recipient}" {
if string :matches "${valid_user}" "True" {
if body :raw :contains ["message/notification"] {
setflag "\\Seen";
fileinto :create "Notifications";
stop;
}
}
}
Where user-verification
is an extprogram which calls API and verify user based on email address then returns boolean (as an output to the console).
Everything works fine when I will remove if string :matches "${valid_user}" "True"
statement other way it looks like is not recognizing valid_user
variable.
When I pipe valid_user
to some script just to capture value for that variable it throws an error:
error: specified :args item `True?' is invalid.
Why question mark was added to the variable in this case?
Thoughts?
In that case "True" is followed by a newline, which Sieve happily reads and includes in the variable value.
To have it fixed user-verification
script must to output it without a new line.