in reply to Re: Re: Getting BCC: header from a message.
in thread Getting BCC: header from a message.

As VSarkiss says, you may need to parse the first (i.e. most recent-- assuming you haven't already used sendmail after receiving the mail from the outside world) "recieved" header
Received: from mail.fromdomain.com (localhost [127.0.0.1]) by mail.domain.com (x.x.x/x.x.x) with ESMTP id Mxxxxxx for <user_ID@domain.com>; Fri, 29 Jun 2001 01:23:45
for the <user_ID@domain.com> since that should have the name of the mailbox the email is intended for.

Replies are listed 'Best First'.
Re: (ichimunki) Re x 3: Getting BCC: header from a message.
by unixdown (Scribe) on Jun 29, 2001 at 20:26 UTC
    This works to a point. If CC is used, this won't work (the Received Header does not contain the "for"). If there is more than one address in the BCC field, only the first is in the received header. (This is all after sendmail forwards the mail to the program. I'm sure its doing some type of manipulation before it hits my mail forwarder.)
      The "envelope-to" is not in the header reliably anywhere. It's in the envelope. If you can't get an envelope-to out-of-band somehow, then you cannot complete your task reliably, and you'll need to back up a step to figure out how to do it instead.

      This is why I hacked sendmail so that envelope-to was available to my .procmailrc as $1. It shows up under Joey Pruett's name because he was the one that submitted the modifications to the sendmail crew.

      -- Randal L. Schwartz, Perl hacker