in reply to Detecting bounced mails

Why are you reinventing Mail::DeliveryStatus::BounceParser?

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re: •Re: Detecting bounced mails
by Corion (Patriarch) on Mar 09, 2004 at 07:56 UTC

    I knew there already was such a module, but I looked (twice) through CPAN and didn't find it, so I rewrote it (and it wasn't hard to do).

    Thanks for finding it for me! Now I'll simply turn my module into some glue and use the other module :-)

      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.

        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.