I suspect you can use sendmail rules to rewrite the headers of the message, so it records the SMTP envelope "To" as a line in the message header, such as "X-Envelope-To".

Once upon a time, I was better at sendmail rules; but since I've switched my server to Exim, it's become a lot easier to handle things like this! ;-)

Update: I looked up the sendmail docs in the Bat Book. How's this for an idea: you could remove the "To" line from the email before it gets processed by sendmail. According to the docs, it will then record an "Apparently-To" header, which takes the address from the envelope.

35.10.2 Apparently-To:

When the message lacks a recipient

(sendmail) If the header of a mail message lacks recipient information (lacks all of the To:, Cc:, and Bcc: header lines), sendmail adds an Apparently-To: header line and puts the recipient's address from the envelope into the field of that line. This behavior is hard-coded into pre-8.7 sendmail, but beginning with version 8.7, it can be tuned with the NoRecipientAction option (see Section 34.8.43).

The Apparently-To: header name is not defined in RFC822. It is added by pre-8.7 sendmail because RFC822 requires at least one To: or Cc: header, and neither is present.

An Apparently-To: header should never be defined in the configuration file.

___
-DA


In reply to Re: Getting BCC: header from a message. by da
in thread Getting BCC: header from a message. by unixdown

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.