in reply to Re: •Re: Detecting bounced mails
in thread Detecting bounced mails

I am new to all of this but need similar help. I found the Mail::DeliveryStatus::BounceParser but do not understand how I might have it parse my inbox to provide the email and reason the email rejected.

Replies are listed 'Best First'.
Re^4: Detecting bounced mails
by Corion (Patriarch) on Sep 07, 2004 at 13:28 UTC

    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.