Alright; I was checking out my profile at it looks like I was working on this same problem 2 years ago. How sad is that?
Actually it has gone in and out of being simi-important to my employer which is why I have not followed through...Anyway...
I have been re-re-tasked with creating a list of bounced e-mail addresses and the reason they bounced. I only get access to the mail after it reaches the exchange server and I can see it through Outlook. That is the extent of my access to the server as well (last time it was suggested that I parse the SMTP logs. While this is a very clever idea, I do not have that much access.)
I have Outlook filtering the bounced messages into a separate folder that I have exported as a CSV. I trimmed this CSV down to a single 'body' column (just to eliminate any gotchas) and am trying to feed it to Mail::DeliveryStatus::BounceParse using DBM::CSV (since otherwise it is hard to figure out whether a new line is the end of a record or just part of a message body.)
There are about 2000 bounce backs per day so I would prefer not having to do this manually ;-)
First question: Will this Bounce Parser work based on the body only or does it need the header of the message?
Second Question: If you can keep from laughing at my code long enough, can you tell me what I have done wrong / does this have any chance of working? As you may be able to tell, it is snippets from wherever I could find them, mashed together and left to ferment.
use Mail::DeliveryStatus::BounceParser; use DBI; my $dbh = DBI->connect("DBI:CSV:") or die "Cannot connect: " . $DBI::e +rrstr; my $in_file = "testcsv"; my $out_file = "bounce_report.csv"; print "WARNING...this program will write over your ",$out_file, " file + in a few sec.\n"; sleep 3; open (REPORT, "+>$out_file") or die "Cant open report file, $!"; print REPORT "Arival_Date,Email,Final_Recipient,Action,Std_Reason,R +eason,SMTP_Code,Status,Diag_Code,Reporting_MTA,Host,Raw\n"; my($query) = "SELECT * FROM $in_file"; my($sth) = $dbh->prepare($query) or die "Cannot prepare: " . $dbh->err +str(); $sth->execute() or die "Cannot execute: " . $sth->errstr(); my($body); $sth->bind_columns(undef, \$body); my $n=0; while ($sth->fetch) { my $bounce = eval { Mail::DeliveryStatus::BounceParser->new( $body ) } +; print $report->get('email'); $n++; } $sth->finish(); $dbh->disconnect(); close REPORT; print "Processing complete. In = ", $n, " records\n";

I get "can't call method "get" on an undefined value at sqlbouncerpt.pl line 20 when I try to run it. Line 20 is
print $report->get('email');
I currently have this line just printing to STDOUT so that I can tell if it works. Once it does, I will enter the rest of the fields and point them to the output file. Any help or a better way to go about this would be very much appreciated.
James

In reply to Mail::DeliveryStatus::BounceParse by jalspach

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.