I'm working on a program that parses an incoming email through a pipe from sendmail. It needs to determine who the email was really sent to since its not guaranteed that the To: field is set to the address that the mail was sent to. Most list servers fill the To: field with the list address. So if the recipient isn't in the To,Apparently-To or the X-Apparently-To fields. How am I to determine who the email was really sent to? Barring that the program looks for a specific domain, the one that the email was sent to makes the job easier.

My take on it is as follows but I'm sure there's a better way.

use Mail::Header to parse out the header of the incoming mail. Look in the To: field and see if the domain matches what we're looking for. If its not, then look in the other fields. If they're not then use Email::Find to parse out the Received field from theMail::Header object and go through the email addresses it returns for a valid one.

BMaximus

In reply to Determining who the email is meant for by BMaximus

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.