> On 20 Oct 2020, at 16:10, Viktor Dukhovni <postfix-us...@dukhovni.org> wrote:
> 
> On Tue, Oct 20, 2020 at 03:08:51PM -0600, @lbutlr wrote:
> 
>> I would like to change this to only bcc mail that is being delivered
>> to local users.
>> 
>> The current setup uses recipient_bcc_maps which I would have thought
>> did what I wanted, but it actually does all outbound mail as well.
> 
> With recipient_bcc_maps, the specified BCC recipient from the RHS of the
> table is added whenever the message envelope contains a recipient that
> matches the LHS of the table.  Therefore, either the outbound mail in
> question also had local recipients, or your table inadvertently matches
> some or all remote recipients.

Right, which means custom m matches for every domain instead of being able to 
just catch the local users.

>> The pcre file for the map is generated each date:
>> 
>> #!/bin/bash
>> 
>> JDATE=$(gdate +%j)
>> cat << EOF > /etc/postfix/rbcc.pcre
>> if !/backup.*@/
>> /^([^+_]*).*@([^.]*)/   backup+${JDATE}.\${1}-\${2}@southgaylord.com
>> endif
> 
> I don't see anything above that limits the matched recipients to local
> users.  Do you?  What is the intent of the "([^.]*)" pattern following
> the "@" sign?  It will always match, possibly an empty string if the
> first character after "@" is ".", but otherwise some initial substring
> of the domain part.

The first character cannot be a . in an email address (u...@.example.com is 
invalid), so it matches the first portions of the domain part of the email 
address. So 'example' in example.com or 'mail' in mail.example.com.

> This also misparses quoted local parts with an address extension:

I'm fine with that. I have no quoted local part emails and if anyone created 
one with a double .. (an obviously attempt to break things) I'd deal with that 
with a clue bat.

> Also, if you're then using the address extension to create filenames, I'd 
> want to exclude more characters from $1 and $2.

The issue is not the saving the email the other backup, that works perfectly 
fine and has no issues. The issue is excluding outbound emails.

> Bottom line, regular expressions are power tools with no safety measures, 
> they cut
> fingers as well as they cut wood.  My advice would be to stick to
> indexed tables whenever possible.

This isn't related to the problem I am trying to solve.

>> So, what would I need to do/change so that message I send to this list
>> )for example) are not archived, but the messages received from the
>> list continue to be archived to the backup user?

> Create an indexed table that only matches local addresses.

So even though postfix must and does know about local domains, I have to tell 
it which domains are local to use bcc maps without including all sent mail?

There's got to be a better way to do this.

-- 
I'd rather have my mind opened by wonder than closed by belief

Reply via email to