<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><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;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
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;}
span.StileMessaggioDiPostaElettronica17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 2.0cm 2.0cm 2.0cm;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=IT link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal>Hi there,<o:p></o:p></p><p class=MsoNormal>on my mail server (postfix, dovecot 2.2.27 in Debian 9) I have an automatic forwarding (with sender_bcc_maps in Postfix) for all the emails sent in smtp from the same server, that are then put in the Sent folder with a sieve rule.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>In this way, however, when a user sends an e-mail to himself, both copies end up in the Sent folder and it's not good.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>To resolve, I tried using the Sieve “duplicate” extension along with “fileinto” but I can't get it to work.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I then activated also the “editheader” extension to better understand what the problem was and I get these results.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Sieve rules without using “fileinto:”<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal style='margin-left:35.4pt'>require ["duplicate", "editheader"];<o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt'>if duplicate { <o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt'>addheader "x-sieve-test1" "duplicate"; <o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt'>}<o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt'>if allof (header :regex ["from"] [".*info@example\.com"], <o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt'>header :regex ["x-sieve-test1"] [".*duplicate"]) { <o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt'>addheader "x-sieve-test2" "confirm duplicate"; <o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt'>stop; <o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt'>} elsif header :regex ["from"] [".*info@example\.com"] { <o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt'>addheader "x-sieve-test3" "not duplicate"; <o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt'>stop;<o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt'>} <o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt'><o:p> </o:p></p><p class=MsoNormal>and I get these headers in the first mail (in INBOX):<o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt'>X-Sieve-Test2: confirm duplicate<o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt'>X-Sieve-Test1: duplicate<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>and in the second email (always in INBOX) this other:<o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt'>X-Sieve-Test3: not duplicate<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Everything works perfectly.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>When I add the fileinto statement to the last if as below<o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt'><o:p> </o:p></p><p class=MsoNormal style='margin-left:35.4pt'>require ["duplicate", "editheader"];<o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt'>if duplicate { <o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt'>addheader "x-sieve-test1" "duplicate"; <o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt'>}<o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt'>if allof (header :regex ["from"] [".*info@example\.com"], <o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt'>header :regex ["x-sieve-test1"] [".*duplicate"]) { <o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt'>addheader "x-sieve-test2" "confirm duplicate"; <o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt'>stop; <o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt'>} elsif header :regex ["from"] [".*info@example\.com"] { <o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt'>addheader "x-sieve-test3" "not duplicate"; <o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt'>fileinto "Sent";<o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt'>stop;<o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt'>}<o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt'><o:p> </o:p></p><p class=MsoNormal>I get a completely incorrect result, both mails in the Sent folder with this header line:<o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt'>X-Sieve-Test3: not duplicate<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>in practice it no longer detects the duplicate email.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>If I use “discard” rather than “fileinto” it works fine and if I put “fileinto” in the first “if” (“if duplicate”) it does’t work. <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I did hundreds of tests but the “duplicate” extension stops working in the presence of the fileinto statement (there are exceptions: if I put the “fileinto” in the second “if” - that is in the middle one instead of the last one - it works fine, but it's not that that I want).<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Any idea how to solve the problem or how to get the same result (one mail in Sent folder and one in INBOX, when a user sends an e-mail to himself) without using the “duplicate” extension?<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Thanks a lot,<o:p></o:p></p><p class=MsoNormal>Luca<o:p></o:p></p></div></body></html>