<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p><br>
</p>
<br>
<div class="moz-cite-prefix">Op 19/09/2018 om 15:07 schreef Adam
Raszkiewicz:<br>
</div>
<blockquote type="cite"
cite="mid:AC6F219B-F853-4410-83C6-45AE979AA13B@contoso.com">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
@font-face
{font-family:inherit;
panose-1:2 11 6 4 2 2 2 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
code
{mso-style-priority:99;
font-family:"Courier New";}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:"Courier New";}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style>
<div class="WordSection1">
<p class="MsoNormal"
style="margin-bottom:12.0pt;background:white;vertical-align:baseline">
<span
style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729">I'm
trying to get blow Sieve filter to work<o:p></o:p></span></p>
<p class="MsoNormal"
style="background:#EFF0F1;vertical-align:baseline"><span
style="font-size:10.0pt;font-family:Consolas;color:#242729;border:none
windowtext 1.0pt;padding:0in;background:#EFF0F1">require
["fileinto", "imap4flags", "mailbox", "body", "envelope",
"vnd.dovecot.pipe", "variables", "vnd.dovecot.execute"];<o:p></o:p></span></p>
<p class="MsoNormal"
style="background:#EFF0F1;vertical-align:baseline"><span
style="font-size:10.0pt;font-family:Consolas;color:#242729;border:none
windowtext 1.0pt;padding:0in;background:#EFF0F1"><o:p> </o:p></span></p>
<p class="MsoNormal"
style="background:#EFF0F1;vertical-align:baseline"><span
style="font-size:10.0pt;font-family:Consolas;color:#242729;border:none
windowtext 1.0pt;padding:0in;background:#EFF0F1">if envelope
:matches "To" "*@*" {<o:p></o:p></span></p>
<p class="MsoNormal"
style="background:#EFF0F1;vertical-align:baseline"><span
style="font-size:10.0pt;font-family:Consolas;color:#242729;border:none
windowtext 1.0pt;padding:0in;background:#EFF0F1"> set
"recipient" "${0}";<o:p></o:p></span></p>
<p class="MsoNormal"
style="background:#EFF0F1;vertical-align:baseline"><span
style="font-size:10.0pt;font-family:Consolas;color:#242729;border:none
windowtext 1.0pt;padding:0in;background:#EFF0F1"> set
"user" "${1}";<o:p></o:p></span></p>
<p class="MsoNormal"
style="background:#EFF0F1;vertical-align:baseline"><span
style="font-size:10.0pt;font-family:Consolas;color:#242729;border:none
windowtext 1.0pt;padding:0in;background:#EFF0F1"> set
"recip_domain" "${2}";<o:p></o:p></span></p>
<p class="MsoNormal"
style="background:#EFF0F1;vertical-align:baseline"><span
style="font-size:10.0pt;font-family:Consolas;color:#242729;border:none
windowtext 1.0pt;padding:0in;background:#EFF0F1">}<o:p></o:p></span></p>
<p class="MsoNormal"
style="background:#EFF0F1;vertical-align:baseline"><span
style="font-size:10.0pt;font-family:Consolas;color:#242729;border:none
windowtext 1.0pt;padding:0in;background:#EFF0F1"><o:p> </o:p></span></p>
<p class="MsoNormal"
style="background:#EFF0F1;vertical-align:baseline"><span
style="font-size:10.0pt;font-family:Consolas;color:#242729;border:none
windowtext 1.0pt;padding:0in;background:#EFF0F1">if envelope
:matches "From" "*" {<o:p></o:p></span></p>
<p class="MsoNormal"
style="background:#EFF0F1;vertical-align:baseline"><span
style="font-size:10.0pt;font-family:Consolas;color:#242729;border:none
windowtext 1.0pt;padding:0in;background:#EFF0F1"> set
"sender" "${0}";<o:p></o:p></span></p>
<p class="MsoNormal"
style="background:#EFF0F1;vertical-align:baseline"><span
style="font-size:10.0pt;font-family:Consolas;color:#242729;border:none
windowtext 1.0pt;padding:0in;background:#EFF0F1">}<o:p></o:p></span></p>
<p class="MsoNormal"
style="background:#EFF0F1;vertical-align:baseline"><span
style="font-size:10.0pt;font-family:Consolas;color:#242729;border:none
windowtext 1.0pt;padding:0in;background:#EFF0F1"><o:p> </o:p></span></p>
<p class="MsoNormal"
style="background:#EFF0F1;vertical-align:baseline"><span
style="font-size:10.0pt;font-family:Consolas;color:#242729;border:none
windowtext 1.0pt;padding:0in;background:#EFF0F1">#Check if
recipient is valid user<o:p></o:p></span></p>
<p class="MsoNormal"
style="background:#EFF0F1;vertical-align:baseline"><span
style="font-size:10.0pt;font-family:Consolas;color:#242729;border:none
windowtext 1.0pt;padding:0in;background:#EFF0F1">if execute
:output "valid_user" "user-verification" "${recipient}" {<o:p></o:p></span></p>
<p class="MsoNormal"
style="background:#EFF0F1;vertical-align:baseline"><span
style="font-size:10.0pt;font-family:Consolas;color:#242729;border:none
windowtext 1.0pt;padding:0in;background:#EFF0F1"> if
string :matches "${valid_user}" "True" {<o:p></o:p></span></p>
<p class="MsoNormal"
style="background:#EFF0F1;vertical-align:baseline"><span
style="font-size:10.0pt;font-family:Consolas;color:#242729;border:none
windowtext 1.0pt;padding:0in;background:#EFF0F1"> if
body :raw :contains ["message/notification"] {<o:p></o:p></span></p>
<p class="MsoNormal"
style="background:#EFF0F1;vertical-align:baseline"><span
style="font-size:10.0pt;font-family:Consolas;color:#242729;border:none
windowtext 1.0pt;padding:0in;background:#EFF0F1">
setflag "\\Seen";<o:p></o:p></span></p>
<p class="MsoNormal"
style="background:#EFF0F1;vertical-align:baseline"><span
style="font-size:10.0pt;font-family:Consolas;color:#242729;border:none
windowtext 1.0pt;padding:0in;background:#EFF0F1">
fileinto :create "Notifications";<o:p></o:p></span></p>
<p class="MsoNormal"
style="background:#EFF0F1;vertical-align:baseline"><span
style="font-size:10.0pt;font-family:Consolas;color:#242729;border:none
windowtext 1.0pt;padding:0in;background:#EFF0F1">
stop;<o:p></o:p></span></p>
<p class="MsoNormal"
style="background:#EFF0F1;vertical-align:baseline"><span
style="font-size:10.0pt;font-family:Consolas;color:#242729;border:none
windowtext 1.0pt;padding:0in;background:#EFF0F1"> }<o:p></o:p></span></p>
<p class="MsoNormal"
style="background:#EFF0F1;vertical-align:baseline"><span
style="font-size:10.0pt;font-family:Consolas;color:#242729;border:none
windowtext 1.0pt;padding:0in;background:#EFF0F1"> }<o:p></o:p></span></p>
<p class="MsoNormal"
style="background:#EFF0F1;vertical-align:baseline"><span
style="font-size:10.0pt;font-family:Consolas;color:#242729;border:none
windowtext 1.0pt;padding:0in;background:#EFF0F1">}<o:p></o:p></span></p>
<p class="MsoNormal"
style="background:white;vertical-align:baseline"><span
style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729"><o:p> </o:p></span></p>
<p class="MsoNormal"
style="background:white;vertical-align:baseline"><span
style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729">Where </span><span
style="font-size:10.0pt;font-family:Consolas;color:#242729;border:none
windowtext 1.0pt;padding:0in;background:#EFF0F1">user-verification</span><span
style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729"> is
an extprogram which calls API and verify user based on email
address then returns boolean (as an output to the console).<o:p></o:p></span></p>
<p class="MsoNormal"
style="background:white;vertical-align:baseline"><span
style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729">Everything
works fine when I will remove </span><span
style="font-size:10.0pt;font-family:Consolas;color:#242729;border:none
windowtext 1.0pt;padding:0in;background:#EFF0F1">if string
:matches "${valid_user}" "True"</span><span
style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729">statement
other way it looks like is not recognizing </span><span
style="font-size:10.0pt;font-family:Consolas;color:#242729;border:none
windowtext 1.0pt;padding:0in;background:#EFF0F1">valid_user</span><span
style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729">variable.<o:p></o:p></span></p>
<p class="MsoNormal"
style="background:white;vertical-align:baseline"><span
style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729">When
I pipe </span><span
style="font-size:10.0pt;font-family:Consolas;color:#242729;border:none
windowtext 1.0pt;padding:0in;background:#EFF0F1">valid_user</span><span
style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729"> to
some script just to capture value for that variable it
throws an error:<o:p></o:p></span></p>
<p class="MsoNormal"
style="background:white;vertical-align:baseline"><span
style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729"><o:p> </o:p></span></p>
<p class="MsoNormal"
style="background:cornsilk;vertical-align:baseline"><span
style="font-size:11.5pt;font-family:"inherit",serif;color:#242729">error:
specified :args item `True?' is invalid.<o:p></o:p></span></p>
<p class="MsoNormal"
style="margin-bottom:12.0pt;background:white;vertical-align:baseline">
<span
style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729"><o:p> </o:p></span></p>
<p class="MsoNormal"
style="margin-bottom:12.0pt;background:white;vertical-align:baseline">
<span
style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729">Why
question mark was added to the variable in this case?<o:p></o:p></span></p>
</div>
</blockquote>
<br>
I am not sure what you're doing, but this works here:<br>
<br>
# user-verification shell script:<br>
#!/bin/bash<br>
<br>
echo -n "False"<br>
<br>
# sieve script:<br>
require ["fileinto", "imap4flags", "mailbox", "body", "envelope",
"vnd.dovecot.pipe", "variables", "vnd.dovecot.execute",
"vnd.dovecot.debug"];<br>
<br>
if envelope :matches "To" "*" {<br>
set "recipient" "${0}";<br>
}<br>
if envelope :localpart :matches "To" "*" {<br>
set "user" "${1}";<br>
}<br>
if envelope :domain :matches "To" "*" {<br>
set "recip_domain" "${1}";<br>
}<br>
<br>
if envelope :matches "From" "*" {<br>
set "sender" "${0}";<br>
}<br>
<br>
#Check if recipient is valid user<br>
<br>
if execute :output "valid_user" "user-verification" "${recipient}" {<br>
if string :matches "${valid_user}" "True" {<br>
debug_log "TRUE";<br>
} else {<br>
debug_log "FALSE";<br>
}<br>
}<br>
<br>
This logs the following in the user log:<br>
<br>
frop: line 22: info: DEBUG: TRUE.<br>
<br>
If I change the script to print something else, it correctly logs
"FALSE".<br>
<br>
Did you perhaps forget "-n" for the echo command? In that case
"True" is followed by a newline, which Sieve happily reads and
includes in the variable value.<br>
<br>
Regards,<br>
<br>
Stephan.<br>
</body>
</html>