Hello.
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.
In the init phase, I have:
my $mb = Mail::Box::Maildir->new( 'folder' => './incoming',
'create' => 1,
'access' => 'rw',
'remove_when_empty' => 0 ) ;
For each run, the relevant part is something like:
foreach my $msg ( $mb->messages( '!seen' ) ) {
$msg->label( 'seen' => 1 ) ;
&process( $msg ) ;
}
and, in 'process':
$msg->delete ;
But which method should be used for synchronising and reading new mails?
At first, I tried to do it with:
$mb->open ;
but 'open' is "not implemented for Maildir".
Then:
$mb->write ;
$mb->update ; # Also tried '->acceptMessages'
But they don't seem to do what I expect (mail coming in _after_ the program
is started never gets noticed).
What's the right way to do it? [Is it that the folder object must be re-created
at each round (using 'new')?]
Best regards,
Gilles
|