The synopsis of Mail::DeliveryStatus::BounceParser tells me that it wants each mail fed to it separately. As you have a file in mbox format containing several mails, you'll have to split up that file first, and then pass the single mails to Mail::DeliveryStatus::BounceParser like this, according to the synopsis:
use strict;
use Mail::DeliveryStatus::BounceParser;
my $mail; # current mail
while (<>) {
if (/^From:/ && $mail) {
my $bounce = eval { Mail::DeliveryStatus::BounceParser->new( $mail
+ ) };
if ($@) {
warn "Got error from M::DS::BP: $@ while parsing input"
} else {
my @addresses = $bounce->addresses;
my @reports = $bounce->reports;
my $orig_message_id = $bounce->orig_message_id;
my $orig_message = $bounce->orig_message;
print "Got bounce for $orig_message_id (@reports)";
};
$mail = "";
};
$mail .= $_;
}
That's all there is to it. The code is untested but should work like that. |