Setup
postfix forwards all mails to an archive@domain user via
always_bcc
,postfix saves all the RCPT TO in
X-Envelope-To
headers to perserve the bcc recipients,postfix deletes
X-Envelope-To
for smtp transfers out for privacy reasons,postfix delivers messages to dovecot via
lmtp
.dovecot uses a sieve script to flush the
X-Envelope-To
for all users except archive@domain.
Problem
There is one X-Envelope-To
for each RCPT TO
initially.
So I would like the sieve script to add a single Bcc
header concatenating several X-Envelope-To
values.
require "fileinto";
require "imap4flags";
require ["editheader", "envelope"];
require "regex";
require ["variables","mime","foreverypart"];
if envelope :is "to" "archive@domain" {
concat = """"";
foreverypart {
if header :regex "X-Envelope-To" "(.*)" {
concat = ${concat} "${1}";
}
}
addheader "Bcc" "${1}";
} else {
deleteheader "X-Envelope-To";
}
Which does not work...
Any easy way to do that in sieve ? Or no other way than an external script ? Or perhaps postfix could concatenate all that but that means a milter ?
Thanks in advance
See other post. One needs an external sieve script in Bash. See proposal in:
Postfix archive preserving Bcc with X-Envelope-To - cleanup confidential X-Envelope-To with Lmtp