Re: Handling 'Maildir' folder

Mark Overmeer <[email protected]> Tue, 27 Apr 2004 22:38:15 +0200
Newsgroups gmane.comp.lang.perl.modules.mail-box
Organization MARKOV Solutions
Message-ID <[email protected]>
Hi Gilles,

You replied to yourself a few times, but now it is time to
intervene, because it is not going in the right direction.

The original idea of MailBox was to process folders and messages
non-interactively and per tasks.  So people who try to use it
interactively, or for a "run-continuously" program will encounter
problems.  On some area's, MailBox has not developed enough for
these tasks.  Sometimes, that has to do with Perl...

* Gilles Sadowski ([email protected]) [040425 14:38]:
> I'm using a 'Mail::Box::Maildir' folder in a long-running program.
> The folder should be read for new mail at regular intervals; and be
> synchronised (deletion of processed mails) between rounds.

What I do myself is:
  write a script which purges the e-mails
  start it every hour with cron

In that case, you avoid the problems you describe.

>   $mb->update ; # Also tried '->acceptMessages'

AcceptMessage is a part of $mb->addMessage, $mb->move, $mb->append etc,
so has nothing to do with "synchronize".

Some foldertypes do support  $mb->update, which is what you need.  However,
Maildir does not have this feature yet.  It's not too hard to implement it,
but I lack the time to test and debug it.

The advantage of Maildir is that mail arriving when you process the
folder cannot disturb your process.  For mbox format folders, that
is much more complicated!

As the documentation states: do NOT call $mb->read and $mb->write
yourself, unless you understand the consequences.  For instance,
understand what Scalar::Util's weaken() does to messages and folders...
-- 
               MarkOv

------------------------------------------------------------------------
drs Mark A.C.J. Overmeer                                MARKOV Solutions
       [email protected]                          [email protected]
http://Mark.Overmeer.net                   http://solutions.overmeer.net