Subject: | Mail::Box::MH is too lazy to perform messageId() right after new() |
Mail::Box::MH->new(...)->messageId(...) always returns undef, becouse messageId() uses 'MB_msgid' field which is not populated at this stage. It's necessary to call messageIds() to fill it:
use Mail::Box::MH;
use Mail::Message;
my $dir = Mail::Box::MH->new(folder=>'./mail',
access => 'rw',
create => 1,
keep_index => 1,
);
my $msg = Mail::Message->build(Subject => 'foo');
$dir->addMessage($msg);
my $mid = $msg->messageId;
print "added $mid\n";
print $dir->messageId($mid)
? "found $mid\n"
: "where's $mid\n";
undef $dir;
$dir = Mail::Box::MH->new(folder=>'./mail',
access => 'rw',
create => 1,
keep_index => 1,
);
print $dir->messageId($mid)
? "found $mid\n"
: "missed $mid\n";
$dir->messageIds;
print $dir->messageId($mid)
? "found $mid\n"
: "missed $mid\n";