开发者

How can I stop Perl's Mail::Box::Manager from removing directories?

I'm using the Perl module Mail::Box::Manager to read messages from a Maildir and move them into another directory. Once the script has finishing processing the mail messages in the Maildir it appears to also remove the cur/ and new/ Maildir directories and the Maildir files/directories need to be recreated.

I don't want the script removing the folders and having to recreate the Maildir structure.

I have something simple like:

#!/usr/bin/perl
use Mail::Box::Manager;

my $cnt = 0;
my $mgr = Mail::Box::Manager->new;
my $folder = $mgr->open( folder => '/home/vmail/mailfolder/',
                     access => 'rw',
                 开发者_如何转开发    type => 'maildir',
                     log => 'DEBUG',
                    );

foreach my $msg ( $folder->messages ) {
    # ... doing some processing of $msg here, then, move the mail for storage

    my $filename = $msg->filename || "NA";
    $filename =~ m#(.*)/new/(.*)$#;

    $mgr->moveMessage("/dir/$filename", 
                      $folder->message($cnt), 
                      create => 1 );
    $cnt++;
}

$folder->close();

Any suggestions greatly received. Thanks.


Add

remove_when_empty => 0,

to the $mgr->open call.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜