Score:0

Dovecot sieve concatenate heqders

cn flag

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

anx avatar
fr flag
anx
foreverypart is for looping over MIME parts, but you are looking for multiple headers in the main message, right?
user3450564 avatar
cn flag
yes, exactly: I am trying to iterate over the headers; I thought perhaps there was a way to use the same function but does not seem so.
user3450564 avatar
cn flag
https://wiki2.dovecot.org/Pigeonhole/Sieve/Plugins/Extprograms: external sieve script may be the simplest with a simple bash script ?
Michael Hampton avatar
cz flag
Does this answer your question? [Postfix archive preserving Bcc with X-Envelope-To - cleanup confidential X-Envelope-To with Lmtp](https://serverfault.com/questions/1077995/postfix-archive-preserving-bcc-with-x-envelope-to-cleanup-confidential-x-envel)
user3450564 avatar
cn flag
Yes, I put the link to my own post as answer. thanks
Score:0
cn flag

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

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.