I am trying to write a smart mail router to collect mail from a POP3 server provided by our ISP and forward on to the intended recipients. Here why. We occasionally receive email at our office that is misaddressed i.e it is sent to fredie@ourdomain.com instead of freddie@ourdomain.com - (the user missed a 'd' out of freddie). Mail that is incorrectly addressed goes to a POP3 'catchall' account provided by our ISP. e.g ourdomian@ourdomain.com I can collect email from this catchall account with POP3Client (OK),apply some guestimations to figure out where the mail was really supposed to go and then forward it on locally or remotely via SMTP. The problem is that I cannot figure out how to reliably identify the recipients email address in the header of the original email I collect via POP3client. The mail Header To: field is obviously unreliable ('Undisclosed ricipients' etc). The topmost Received: field in the message Header contains an indented ' for <address>' that looks promising, but even this does not identify the genuine intended recipient where mails are sent to us by our ISP's list server (although in these cases the To: field is valid!). Is there information loss from the Header when POP3 email is collected that makes the task impossible? Is the unknown 'recipient for field' only going to be a problem with mail from our ISP's list server? Is there a better way to do this, rather than collecting with a POP3 Client in the first place? Any help much appreciated!

In reply to Routing mail collected from a POP3 Server by Anonymous Monk

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.