I have the following sieve script:
require ["enotify","body","regex","imap4flags","variables"];
if header :is "subject" "Sie haben eine Zahlung erhalten"
{
if body :regex "Sie haben ([0-9,]+(\\.\\d{2})?) € EUR erhalten" {
notify :importance "2" :message "Sie haben ${1} EUR erhalten" "mailto:xxxx@xxxx.com";
setflag "\\Seen";
}
}
But ${1}
is not filled with my regex
Also tried to first set ${1}
to a defined variable, also not working.
What am I doing wrong?
The notifier itself is working, I get a mail but without a value.
I want to extract the amount from a body text:
Sie haben 15,00 € EUR erhalten
So my regex should give me 15,00
.
I'm not sure why, but body
extension with :regex
can not capture regex groups, but you still can use foreverypart
and extracttext
to assign body content into variable, so that string :regex
can capture them.
Dovecot Pigeonhole Sieve's regex is quite limited, you can't use something like \d
.
require ["enotify","regex","imap4flags","variables","foreverypart","extracttext"];
if header :is "subject" "Sie haben eine Zahlung erhalten"
{
foreverypart {
extracttext "body";
if string :regex "${body}" "Sie haben ([0-9,]+(\\.[0-9]{2})?) € EUR erhalten" {
notify :importance "2" :message "Sie haben ${1} EUR erhalten" "mailto:xxxx@xxxx.com";
setflag "\\Seen";
break;
}
}
}