On Tue, Oct 20, 2020 at 05:29:22PM -0600, @lbutlr wrote:

> >> 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.

No, it just means that the table should not match remote recipients, how
that is done depends on the table type.

> > 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.

Lossy, but if you just want the first label, so be it.  What is your
definition of a "local" recipient?  Do you literally mean a mailbox
handled via local(8), aliases(5) and delivery to a unix-account, or do
you mean anything you're willing to accept inbound?

If you're abusing terminology and really "local" as in local address
class, then with an indexed table, bare lookup keys only match local
recipients (the domain matches $myorigin or $mydestination).  Of
course you then need to list each user.  Since you're generating
the map anyway:

    getent passwd | awk -F: '{print $1}' | ...

> > 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.

I don't recommend waiting for broken edge-cases to show in practice, but
your system your rules...

> > 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.

Well it is, if by "local" you mean local address class.

Otherwise, the simplest solution is to completely separate
inbound and outbound mail either with multiple instances,
or just separate smtpd(8) and cleanup(8) instances.

Then your recipient bcc table would never see the outbound
mail in the first place.

-- 
    Viktor.

Reply via email to