[Dovecot] Sieve & Adding headers.

Stephan Bosch stephan at rename-it.nl
Thu Jul 26 22:34:11 EEST 2012


On 7/26/2012 12:08 PM, Steven Haigh wrote:
> On 25/07/2012 7:12 PM, Stephan Bosch wrote:
>
> I'd just like to say a quick thanks to Stephan for his help.
>
> I've built 2.1.8 using an updated .spec from the older ATRPMs src.rpm 
> and also built 0.3.1 of dovecot-pigeonhole.
>
> The Extensions section of the Server Sieve Capabilities shows 
> editheader now as well as a couple of others. I've made the 
> modifications using the example posted by Stephan earlier in this thread.
>
> I'm wondering how the regex works. ie: I've used:
> if header :regex "subject" "\\[SCIENTIFIC-LINUX-DEVEL\\] *(.*)"
>
> Will this also match a subject of "Re: [SCIENTIFIC-LINUX-DEVEL] ...." 
> as well?
>
> I'm a bit unsure how the matching will work in this case.
>
Well, it will match in that case. But my example will also remove the 
'Re:' prefix in that case: there is no '^' at the beginning of the 
regex, so the regex can match somewhere in the middle of the subject. 
You can adjust the regex to match a 'Re:' prefix (and whatever else you 
want to allow) and retain that in a match variable as well:

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

if address "sender" "owner-scientific-linux-devel at LISTSERV.FNAL.GOV" {
   if header :regex "subject" "((Re|Fwd): *)\\[SCIENTIFIC-LINUX-DEVEL\\] 
*(.*)" {
     deleteheader "Subject";
     addheader "Subject" "${1}${3}";
}
    addheader "List-Post" "<mailto:scientific-linux-devel at fnal.gov>";

    fileinto "Mail List.SL-Devel";
}

Something like that.

Regards,

Stephan.



More information about the dovecot mailing list