Hello esteemed code fellows

Tired of receiving a couple thousands of mail bounces a day, I'm trying to figure out how to build a script that can work as a non valid email addresses parser.

The idea is to trigger it through the mail alias, and make it read the email address that had delivery problems, and also the cause. This way, I can freeze that user on the DB, so his sales stop (the guy's email has problems, so I'd better stop offering people his merchandise).

The error message that comes at the message body seems not to be a very regular pattern. But I noticed that all the delivery error messages come with a "delivery report.dat" file, wich seems to have a perfect regular pattern for parsing. Below some examples of their contents.

Reporting-MTA: dns; me.mysite.com X-Postfix-Queue-ID: AC07B204DA X-Postfix-Sender: rfc822; me@mysite.com Arrival-Date: Sun, 2 Nov 2008 09:01:23 -0200 (CST) Final-Recipient: rfc822; vivafonte@hotmail.com Action: failed Status: 5.0.0 Remote-MTA: dns; mx4.hotmail.com Diagnostic-Code: smtp; 550 Requested action not taken: mailbox unavail +able Reporting-MTA: dns; me.mysite.com X-Postfix-Queue-ID: 77B42205D8 X-Postfix-Sender: rfc822; me@mysite.com Arrival-Date: Sun, 2 Nov 2008 10:00:07 -0200 (CST) Final-Recipient: rfc822; r929302@metroweb.sp.gov.br Action: failed Status: 5.4.4 Diagnostic-Code: X-Postfix; Host or domain name not found. Name servic +e error for name=metroweb.sp.gov.br type=A: Host not found Reporting-MTA: dns; me.mysite.com X-Postfix-Queue-ID: B7EB92052C X-Postfix-Sender: rfc822; me@mysite.com Arrival-Date: Sun, 2 Nov 2008 10:00:04 -0200 (BRST) Final-Recipient: rfc822; cronusmg@yahoo.com Action: failed Status: 5.0.0 Remote-MTA: dns; f.mx.mail.yahoo.com Diagnostic-Code: smtp; 554 delivery error: dd This user doesn't have a yahoo.com account (cronusmg@yahoo.com) [-5] - mta208.mail.mud.yaho +o.com

Has anyone built something like this? I am not sure about how to do the parsing of this .dat file inside the email message.

Thanks a lot, fellows

Andre


In reply to Mail Delivery System report parser by Andre_br

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.