[Dovecot] Sieve & Adding headers.

Stephan Bosch stephan at rename-it.nl
Wed Jul 25 10:16:35 EEST 2012


On 7/25/2012 3:56 AM, Steven Haigh wrote:
> Hi all,
>
> I've just migrated my mail system from procmail to managesieve/sieve 
> and I'm having trouble trying to duplicate a could of rules I used to 
> use in my procmail config.
>
> One particular rule would be this:
> :0 Wfh
> * ^Sender: owner-scientific-linux-devel at LISTSERV.FNAL.GOV
> | (sed -e '/^Subject:/ s/\[SCIENTIFIC-LINUX-DEVEL\] *//g'| sed 
> ':a;N;$!ba;s/Precedence: list/Precedence: list\nList-Post: 
> <mailto:scientific-linux-devel at fnal.gov>/g')
> :0 A
> .Mail\ Lists.SL-Devel/
>
> This in effect adds the header "List-Post: 
> <mailto:scientific-linux-devel at fnal.gov>" after "Precedence: list". 
> This allows me to use the Reply To List functionality in Thunderbird.
>

You'll need the editheader extension (meaning a fairly new Pigeonhole 
v0.3.0+):

require ["fileinto", "editheader", "variables", "regex"];

if address "sender" "owner-scientific-linux-devel at LISTSERV.FNAL.GOV" {
   if header :regex "subject" "\\[SCIENTIFIC-LINUX-DEVEL\\] *(.*)" {
     deleteheader "Subject";
     addheader "Subject" "${1}";
}

    addheader "List-Post" "<mailto:scientific-linux-devel at fnal.gov>";

    fileinto "Mail List.SL-Devel";
}

> Another rule is:
> :0 Wfh
> * ^X-BeenThere: users at lists.repoforge.org
> | sed -e '/^Subject:/ s/\[users\] *//g'
> :0 A
> .Mail\ Lists.RPMForge/
>
> This removes the [users] tag from the subject of each message to the 
> RPMForge / RepoForge mailing lists.
>
> Is there a way to do this with sieve? Nothing I have seen seems to do 
> this - however I'm only a beginner in this area.
>
> Please CC myself as well as the list. I'm not currently subscribed.
>

require ["fileinto", "editheader", "variables", "regex"];

if header "X-BeenThere" "users at lists.repoforge.org" {
   if header :regex "subject" "\\[users\\] *(.*)" {
     deleteheader "Subject";
     addheader "Subject" "${1}";
   }
   fileinto "Mail Lists.RPMForge";
}


Don't forget to enable the editheader extension in your configuration 
using the sieve_extensions setting.

Regards,

Stephan.



More information about the dovecot mailing list