On Thu, Feb 12, 2009 at 07:18:56AM -0500, Wietse Venema wrote:

> /etc/postfix/sender_access:
>    /(.*)/  prepend X-Envelope-From: <$1>
> 
> /etc/postfix/check_recipient_access:
>    /(.*)/  prepend X-Envelope-To: <$1>
> 
> Beware, this breaks the privacy of BCC recipients.

Note also that the addresses in question will not be in RFC822 form,
they will in Postfix internal (i.e. de-quoted) form. So for example:

        MAIL FROM:<"spaces in this mailbox"@example.com>

will appear as:

    X-Envelope-From: spaces in this mail...@example.com

Adding quoting is possible (PCRE):

    # Reject addresses with <"> in the localpart or domain
    #
    /"/         REJECT
    # Use dot-a...@domain verbatim (untested)
    #
    
/([^\x00-\x20\x7f-\xff\(\)<>@,;:\\\[\]\.]+(?:\.[^\x00-\x20\x7f-\xff\(\)<>@,;:\\\[\]\.]+)*...@[^@]*)/
 PREPEND X-Envelope-From: <$1>
    # Everthing else needs quoting:
    #
    /(.*)@(.*)/ PREPEND X-Envelope-From: <"${1}"@${2}>

provided you are willing to REJECT (often problematic and in any case
rare) addresses whose de-quoted (internal) form contains double-quotes:

        <"there are \"quotes\" in this mailbox"@example.com>

If you want to handle these correctly, you need  a content filter or
milter with robust address parsing. Note, parsing RFC822 addresses
*correctly* is NOT easy.

-- 
        Viktor.

Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the "Reply-To" header.

To unsubscribe from the postfix-users list, visit
http://www.postfix.org/lists.html or click the link below:
<mailto:majord...@postfix.org?body=unsubscribe%20postfix-users>

If my response solves your problem, the best way to thank me is to not
send an "it worked, thanks" follow-up. If you must respond, please put
"It worked, thanks" in the "Subject" so I can delete these quickly.

Reply via email to