Hi there,
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.
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.
To resolve, I tried using the Sieve "duplicate" extension along with "fileinto" but I can't get it to work.
I then activated also the "editheader" extension to better understand what the problem was and I get these results.
Sieve rules without using "fileinto:"
require ["duplicate", "editheader"];
if duplicate {
addheader "x-sieve-test1" "duplicate";
}
if allof (header :regex ["from"] [".*info@example\.com"],
header :regex ["x-sieve-test1"] [".*duplicate"]) {
addheader "x-sieve-test2" "confirm duplicate";
stop;
} elsif header :regex ["from"] [".*info@example\.com"] {
addheader "x-sieve-test3" "not duplicate";
stop;
}
and I get these headers in the first mail (in INBOX):
X-Sieve-Test2: confirm duplicate
X-Sieve-Test1: duplicate
and in the second email (always in INBOX) this other:
X-Sieve-Test3: not duplicate
Everything works perfectly.
When I add the fileinto statement to the last if as below
require ["duplicate", "editheader"];
if duplicate {
addheader "x-sieve-test1" "duplicate";
}
if allof (header :regex ["from"] [".*info@example\.com"],
header :regex ["x-sieve-test1"] [".*duplicate"]) {
addheader "x-sieve-test2" "confirm duplicate";
stop;
} elsif header :regex ["from"] [".*info@example\.com"] {
addheader "x-sieve-test3" "not duplicate";
fileinto "Sent";
stop;
}
I get a completely incorrect result, both mails in the Sent folder with this header line:
X-Sieve-Test3: not duplicate
in practice it no longer detects the duplicate email.
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.
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).
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?
Thanks a lot,
Luca