On Thu, Apr 24, 2025 at 10:21:37AM +0300, Mike Teplynin via Postfix-users wrote:

> On Thu, Apr 24, 2025 at 9:46 AM Viktor Dukhovni via Postfix-users
> <postfix-users@postfix.org> wrote:
> 
> > Well, that's rather important information, that wasn't originally
> > provided.  So this an email archiving use case.  In that case,
> > might it not be possibl/desirable to archive a separate copy
> > of each message, that isn't the copy delivered to the user?
> 
> Yes, it's about email archiving on edge server, even before relaying
> messages to internal servers for checking for spam, viruses, etc.
> Currently i'm adding headers in the messages and then do always_bcc
> for send to storage server. I don't need to keep separate copies of
> letters for each user, it is enough to save the original letter, but
> with adding some information from the smtp session (evelope from,
> envelope to, and may be hello too).
> 
> As I mentioned earlier, full session log from Sendmail was perfect
> solution for us, but Postfix does not have such functionality.

So you are generating separate copies (always_bcc), but you SHOULD
instead use "recipient_bcc_maps", which makes it possible to encode the
original address in the localpart of the per-recipient Bcc address,
and the resulting envelope can be moved into the message content or
headers as part of the bcc delivery process somewhere along the path.

    main.cf:
        indexed = ${default_database_type}:${config_directory}/
        pcre = pcre:${config_directory}/
        recipient_bcc_maps = ${pcre}rcpt_bcc.pcre
        transport_maps = ${indexed}transport

    rcpt_bcc.pcre:
        # Handle quoted localparts first
        /^"(.*)"@(.*)/  "rcpt-bcc+$1@$2"@quoted.bcc.invalid
        # Then the rest
        /^(.*)@(.*)/    "rcpt-bcc+$1@$2"@bcc.invalid

    transport:
        # Set RHS as desired, receiving SMTP server
        # can transform the message as desired, decoding
        # the "rcpt-bcc+(...)@....bcc.invalid" addresses to
        # recover the original form.
        bcc.invalid      relay:[archive.example]:12345
        .bcc.invalid     relay:[archive.example]:12345

This is a sketch, fill in the details and test with care.

-- 
    Viktor.
_______________________________________________
Postfix-users mailing list -- postfix-users@postfix.org
To unsubscribe send an email to postfix-users-le...@postfix.org

Reply via email to