[Dovecot] Quick question on sieve
I have a procmail recipe that does the majority of my heavy lifting for my mailing lists. It's pretty straightforward, but as I understand it, this isn't something sieve can do:
# [ ] contains a space and a tab :0
- 9876543210^0 ^(List-Id:.*<|X-Mailing-List:[ ]*)\/[-A-z0-9_+]+
- 9876543210^0 ^(List-Post:[ ]*(<mailto:)?|List-Owner:[ ]*(<mailto:)?owner-)\/[-A-Z0-9_+]+
- 9876543210^0 ^(Sender:[ ]*owner-|X-BeenThere:[ ]*|Delivered-To:[ ]*mailing list )\/[-A-Za-z0-9_+]+
- 9876543210^0 ^Sender:.* List"? <(mailto:)?\/[-A-Z0-9_+]+ { LISTNAME=$MATCH }
Basically, it checks the headers for any one of the headers
List-ID: List-Post: List-Owner: Sender: owner- X-BeenThere: Delivered-To: Sender:.*List
and parses out the name of the list, writing it to the LISTNAME variable
For the vast majority of mailing lists the message is then written to
.$LISTNAME/
This means that, by default, a new mailing list is automatically sorted to its own mailbox without my doing anything at all.
Is this something hat Sieve can do? Does it have variable assignment?
-- <div id="me"><div id="Dennis Miller>It's just my opinion. I could be wrong.</div>But I'm not.</div>
On 11/19/2013 11:00 PM, LuKreme wrote:
I have a procmail recipe that does the majority of my heavy lifting for my mailing lists. It's pretty straightforward, but as I understand it, this isn't something sieve can do:
# [ ] contains a space and a tab :0
- 9876543210^0 ^(List-Id:.*<|X-Mailing-List:[ ]*)\/[-A-z0-9_+]+
- 9876543210^0 ^(List-Post:[ ]*(<mailto:)?|List-Owner:[ ]*(<mailto:)?owner-)\/[-A-Z0-9_+]+
- 9876543210^0 ^(Sender:[ ]*owner-|X-BeenThere:[ ]*|Delivered-To:[ ]*mailing list )\/[-A-Za-z0-9_+]+
- 9876543210^0 ^Sender:.* List"? <(mailto:)?\/[-A-Z0-9_+]+ { LISTNAME=$MATCH }
Basically, it checks the headers for any one of the headers
List-ID: List-Post: List-Owner: Sender: owner- X-BeenThere: Delivered-To: Sender:.*List
and parses out the name of the list, writing it to the LISTNAME variable
For the vast majority of mailing lists the message is then written to
.$LISTNAME/
This means that, by default, a new mailing list is automatically sorted to its own mailbox without my doing anything at all.
Is this something hat Sieve can do? Does it have variable assignment?
Yes and yes. I'd normally translate the above Procmail recipe for you, but it is a bit hard to read because my Procmailese is a bit rusty regarding regular expressions. So I'll just work with your question. A very simple example looks as follows:
require "variables"; require "fileinto";
if header :matches "list-id" "*" { set "listname" "${1}"; }
fileinto "$listname";
The mailbox dot prefix is implicit (assuming it is a maildir). To fully translate your recipe, you'll probably need the regex extension (http://tools.ietf.org/html/draft-murchison-sieve-regex-08) as well. The (match) variables are documented in RFC 5229 (http://tools.ietf.org/html/rfc5229).
Regards,
Stephan.
On 19 Nov 2013, at 15:36 , Stephan Bosch <stephan@rename-it.nl> wrote:
This means that, by default, a new mailing list is automatically sorted to its own mailbox without my doing anything at all.
Yes and yes. I'd normally translate the above Procmail recipe for you, but it is a bit hard to read because my Procmailese is a bit rusty regarding regular expressions. So I'll just work with your question. A very simple example looks as follows:
require "variables"; require "fileinto";
if header :matches "list-id" "*" { set "listname" "${1}"; }
fileinto "$listname";
That's good to know (and the first time I've seen a sieve example with variables.
Will: :matches "list-id" "*" {
match the entire line after List-ID? desk set "list name" "${1}" trap the first term, or is $1 the entire match to EOL? If it's not the first word, is it possible to match the first word without installing the regex package with sieve? (I'm loath to install anything extra at this point)
for example, for this list, the list-id is
List-Id: Dovecot Mailing List <dovecot.dovecot.org>
Which is not a good name for fileinto "$listname"
To fully translate your recipe, you'll probably need the regex extension (http://tools.ietf.org/html/draft-murchison-sieve-regex-08) as well. The (match) variables are documented in RFC 5229 (http://tools.ietf.org/html/rfc5229).
<off to read>
Regards,
Thanks!
-- Transvestite: A guy who likes to eat, drink and be Mary.
On 11/20/2013 1:14 AM, LuKreme wrote:
That's good to know (and the first time I've seen a sieve example with variables.
Will: :matches "list-id" "*" {
match the entire line after List-ID?
yes.
desk set "list name" "${1}" trap the first term, or is $1 the entire match to EOL?
${0} is the entire match afaik, ${1} is the first.
If it's not the first word, is it possible to match the first word without installing the regex package with sieve? (I'm loath to install anything extra at this point)
regex is part of the main Pigeonhole distribution. A simple require "regex";
at the top of the script is enough to enable it.
for example, for this list, the list-id is
List-Id: Dovecot Mailing List <dovecot.dovecot.org>
Which is not a good name for fileinto "$listname"
if header :matches "list-id" "*<*>*" { set "listname" "${2}"; }
fileinto "${listname}";
Be careful with '.' in folder names though. For the default Maildir that is the folder separator.
Regards,
Stephan.
participants (2)
-
LuKreme
-
Stephan Bosch