Subject: dynamic naming & creation of mailboxes

From: "Andrew Hammond" <[email-masked]>
Date: Mon, 16 Dec 2002 12:36:50 -0500

Hi folks.

I'm looking to create a new sub-folder / day setup for an mailbox that gets
a couple of hundred messages every day.  Then automatically deliver messages
to today's folder.

I've checked the mailing list archives, googled, and read the Sieve RFC.  It
looks to me like there's now way to do this easily with Sieve.

My current solution is a perl script run by a cron job that makes the
sub-folder and writes a new .sieve.

Is there a better way to do this?

---

From: Cyrus Daboo <[email-masked]>
Date: Mon, 16 Dec 2002 13:07:52 -0500

Hi Andrew,

--On Monday, December 16, 2002 12:36 PM -0500 Andrew Hammond 
<[email-masked]> wrote:

| I'm looking to create a new sub-folder / day setup for an mailbox that
| gets a couple of hundred messages every day.  Then automatically deliver
| messages to today's folder.
|
| I've checked the mailing list archives, googled, and read the Sieve RFC.
| It looks to me like there's now way to do this easily with Sieve.
|
| My current solution is a perl script run by a cron job that makes the
| sub-folder and writes a new .sieve.
|
| Is there a better way to do this?

Why not leave the sieve script set to deliver into a mailbox called 
'sent-active' all the time, then simply have the perl script rename that to 
yesterday's date and recreate the active mailbox again. You then do not 
need to edit the sieve script each day. The only problem with this is a 
possible race condition in which a message delivery to the mailbox is 
attempted between the rename and re-create actions. An alternative might be 
to create yesterday's mailbox and then copy all messages from the active 
one into that and expunge those. That way the active mailbox is around all 
the time avoiding the race. However, that requires a lot more work on the 
IMAP side as you have to select (open) the mailbox to do the copying.

-- 
Cyrus Daboo

---

From: Ken Murchison <[email-masked]>
Date: Mon, 16 Dec 2002 13:23:12 -0500

> IMAP side as you have to select (open) the mailbox to do the copying.

Or you could have the messages delivered to a dummy user's INBOX and
then rename the INBOX.  Renaming an INBOX in IMAP has special semantics
in which the messages are copied to the destination mailbox without
deleting the INBOX.  This is the same as Cyrus' idea, but makes the
server do the bulk of the work for you.

Ken
-- 
Kenneth Murchison     Oceana Matrix Ltd.
Software Engineer     21 Princeton Place
716-662-8973 x26      Orchard Park, NY 14127
--PGP Public Key--    http://www.oceana.com/~ken/ksm.pgp

---

From: Kjetil Torgrim Homme <[email-masked]>
Date: 17 Dec 2002 00:19:19 +0100

[Andrew Hammond]:
>
>   I'm looking to create a new sub-folder / day setup for an mailbox
>   that gets a couple of hundred messages every day.  Then
>   automatically deliver messages to today's folder.
>   
>   I've checked the mailing list archives, googled, and read the
>   Sieve RFC.  It looks to me like there's now way to do this easily
>   with Sieve.

I'm currently writing a draft for an extension allowing expansion
inside strings.  the main motivation for it is to allow access to back
references in regular expressions.  with that in place (I hope to hack
an implementation during Christmas :-), you could do

  require ["fileinto", "regex", "stringexpand"];

  if header :regex ["date"] ", ([0-3]?[0-9]) ([A-Z][a-z]{2}) ([0-9]{4})" {
        let "year"  "${3}";
        let "month" "${2}";
        let "day"   "${1}";
        fileinto "INBOX.${year}-${month}-${day}";
  }

this is a bit awkward, though, and you are not guaranteed that the
Date header will comply with RFC 2822 grammar.  (most of the bogus
Date headers would probably be found in spam messages, though.)

perhaps the extension should include built-in variable names for time
of day.  hmm.

BTW, my extension really is three things in one:

  string expansion  (changes the semantics of doublequoted strings)
  variable setting  ("let" keyword)
  new test "string" (e.g., if string :regex "${year}" "2..." { ...})

should this be split into two or three different extensions?  what do
you guys think?

>   My current solution is a perl script run by a cron job that makes
>   the sub-folder and writes a new .sieve.
>   

hopefully, there will be.

-- 
Kjetil T.			|  read and make up your own mind
				|  http://www.cactus48.com/truth.html

---

From: Kjetil Torgrim Homme <[email-masked]>
Date: 21 Dec 2002 15:37:51 +0100

[Kjetil Torgrim Homme]:
>   inside strings.  the main motivation for it is to allow access to
>   back references in regular expressions.

here it is.  any comments welcome!  (I have not submitted this to the
IETF, I don't quite understand how the procedure works.)