procmail
[Top] [All Lists]

Re: Extracting envelope to

1997-09-30 16:40:27
Geoff Mulligan <geoff(_at_)mulligan(_dot_)com> writes:
Is there any way to extract the envelope TO as opposed to the header TO: using
procmail or formail?

I have procmail running as a system wide mail filter and based on the intended
recipient I'd like to do some specific filtering, but the header To: or cc:
fields may not contain the local recipient, but rather a mailing list name or
multiple recipients.

Is there some way to find the actual local recipient of this message?

There is, in general, no way to _extract_ the envelope recipient(s) from
the message, as it is out-of-band information.  However, if procmail is
being called from sendmail, then the envelope information is usually
passed to procmail as extra arguments, given after the name of the rc
file.  These are availible to the rc file as $1, $2, etc.  You generally
work with these by copying the relevant value into a normal variable
which can then be tested using the "var ??" condition syntax.

For example, in a sendmailV8 config file, the sendmail mailer named
'procmail' generally calls procmail the program with arguments that
look like:

        procmail -f <envelope-sender> -Y -m procmail.rc.file \
                <envelope-sender> <envelope-recipient>

(The leading "-f <envelope-sender>" was added in 8.8.7, I think.)

Then the rc.file would say:

        SENDER = $1
        RECIPT = $2

        :0
        * RECIPT ?? ^^someone@
        {
            # special filtering
        }

However, if you're just checking for specific users, it would be better
to do that filtering in their .procmailrc files, as the above has to be
checked for every single recipient, not just them.


Philip Guenther

<Prev in Thread] Current Thread [Next in Thread>