[pfx] Re: always_bcc colliding with access(5) REDIRECT action

2024-08-01 Thread Wietse Venema via Postfix-users
Viktor Dukhovni via Postfix-users:
> On Wed, Jul 31, 2024 at 01:10:46PM -0400, Wietse Venema via Postfix-users 
> wrote:
> 
> > > > Now I tried to redirect mails from my private address sent to anybody
> > > > at charite.de to be redirected to someone else in the organisation,
> > > > like this:
> > > > 
> > > > rxlf.hildebra...@gmail.com REDIRECT toscx.hrn...@charite.de
> > 
> > Added to the text for REDIRECT actions:
> > 
> > Note 2: a REDIRECT address is subject to canonicalization (add
> > missing domain) but NOT subject to canonical, masquerade, bcc,
> > or virtual alias mapping.
> > 
> > Note the difference with automatic BCC recipients. The reason for
> > this difference is not obvious because it is purely technical.
> > 
> > The excluded mappings are in the code path that generates ordinary
> > recipient records, and the REDIRECT address is not in an ordinary
> > recipient record.
> > 
> > This could be fixed (reuse the code path) but it is a rare edge case.
> > It would open the possibiliy to redirect to multiple recipients.
> 
> Address rewriting of course happens in cleanup, while REDIRECT actions
> are processed in qmgr(8), and is much simpler when it is just one
> explicit address.
> 
> Making REDIRECT match na?ve user expectations, means new rewriting of
> REDIRECT in cleanup(8) potentially yielding multiple REDIRECT
> recipients.  And new logic in qmgr(8) to handle multiple redirect
> recipients.
> 
> And of course, we'd probably still want the last "REDIRECT" access(5)
> action to replace any prior redirects, rather than append to a list,
> which probably means buffering the REDIRECT recipient util EOM, and
> sending just that last one to cleanup(8) as one of the post-message
> envelope records.
> 
> A non-trivial change, but perhaps something that most users would
> reasonably expect?

It's called 'technical debt' when a quick hack has non-obvious
limitations.

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


[pfx] Re: [ext] Re: always_bcc colliding with access(5) REDIRECT action

2024-08-01 Thread Ralf Hildebrandt via Postfix-users
* Viktor Dukhovni via Postfix-users :

> Making REDIRECT match naïve user expectations,

ey! :)

-- 
Ralf Hildebrandt
  Geschäftsbereich IT | Abteilung Netz | Netzwerk-Administration
  Invalidenstraße 120/121 | D-10115 Berlin
  Tel. +49 30 450 570 155 | Fax: +49 30 450 570 962
  ralf.hildebra...@charite.de | https://www.charite.de

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


[pfx] Re: always_bcc colliding with access(5) REDIRECT action

2024-08-01 Thread Viktor Dukhovni via Postfix-users
On Wed, Jul 31, 2024 at 01:10:46PM -0400, Wietse Venema via Postfix-users wrote:

> > > Now I tried to redirect mails from my private address sent to anybody
> > > at charite.de to be redirected to someone else in the organisation,
> > > like this:
> > > 
> > > rxlf.hildebra...@gmail.com REDIRECT toscx.hrn...@charite.de
> 
> Added to the text for REDIRECT actions:
> 
> Note 2: a REDIRECT address is subject to canonicalization (add
> missing domain) but NOT subject to canonical, masquerade, bcc,
> or virtual alias mapping.
> 
> Note the difference with automatic BCC recipients. The reason for
> this difference is not obvious because it is purely technical.
> 
> The excluded mappings are in the code path that generates ordinary
> recipient records, and the REDIRECT address is not in an ordinary
> recipient record.
> 
> This could be fixed (reuse the code path) but it is a rare edge case.
> It would open the possibiliy to redirect to multiple recipients.

Address rewriting of course happens in cleanup, while REDIRECT actions
are processed in qmgr(8), and is much simpler when it is just one
explicit address.

Making REDIRECT match naïve user expectations, means new rewriting of
REDIRECT in cleanup(8) potentially yielding multiple REDIRECT
recipients.  And new logic in qmgr(8) to handle multiple redirect
recipients.

And of course, we'd probably still want the last "REDIRECT" access(5)
action to replace any prior redirects, rather than append to a list,
which probably means buffering the REDIRECT recipient util EOM, and
sending just that last one to cleanup(8) as one of the post-message
envelope records.

A non-trivial change, but perhaps something that most users would
reasonably expect?

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


[pfx] Re: [ext] Re: always_bcc colliding with access(5) REDIRECT action

2024-08-01 Thread Ralf Hildebrandt via Postfix-users
* Wietse Venema via Postfix-users :

> Is this an unexpanded virtual alias?

Yes

> The 'redirect' recipient is not subject
> to canonical mapping, masquerading, or virtual alias mapping.

That explains it.

> There were two recipients: the BCC recipient that was found in
> recipient_bcc_maps, and the RCPT TO recipient that was used to
> search recipient_bcc_maps.

Yes
 
> Let's first see why toscx.hrn...@charite.de' is bounced. 

Probably, because no address expansion was made.

-- 
Ralf Hildebrandt
  Geschäftsbereich IT | Abteilung Netz | Netzwerk-Administration
  Invalidenstraße 120/121 | D-10115 Berlin
  Tel. +49 30 450 570 155 | Fax: +49 30 450 570 962
  ralf.hildebra...@charite.de | https://www.charite.de

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


[pfx] Re: always_bcc colliding with access(5) REDIRECT action

2024-07-31 Thread Wietse Venema via Postfix-users
I have updated some documentation:

> > We have an always_bcc setup in place for incoming mails:
> > 
> > recipient_bcc_maps = pcre:/etc/postfix/backup_bcc.pcre
> > 
> > /^(.*)@charite\.de$/backup+${1}=charite.de@backup.invalid

Added to the text for always_bcc, sender_bcc_maps, recipient_bcc_maps:

Note: automatic BCC recipients are subject to address
canonicalization (add missing domain), canonical_maps,
masquerade_domains, and virtual_alias_maps.

I think that automatic BCC recipients should not generate BCC recipients,
to avoid a program loop.

> > Now I tried to redirect mails from my private address sent to anybody
> > at charite.de to be redirected to someone else in the organisation,
> > like this:
> > 
> > rxlf.hildebra...@gmail.com REDIRECT toscx.hrn...@charite.de

Added to the text for REDIRECT actions:

Note 2: a REDIRECT address is subject to canonicalization (add
missing domain) but NOT subject to canonical, masquerade, bcc,
or virtual alias mapping.

Note the difference with automatic BCC recipients. The reason for
this difference is not obvious because it is purely technical.

The excluded mappings are in the code path that generates ordinary
recipient records, and the REDIRECT address is not in an ordinary
recipient record.

This could be fixed (reuse the code path) but it is a rare edge case.
It would open the possibiliy to redirect to multiple recipients.

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


[pfx] Re: always_bcc colliding with access(5) REDIRECT action

2024-07-31 Thread Wietse Venema via Postfix-users
Ralf Hildebrandt via Postfix-users:
> We have an always_bcc setup in place for incoming mails:
> 
> recipient_bcc_maps = pcre:/etc/postfix/backup_bcc.pcre
> 
> /^(.*)@charite\.de$/backup+${1}=charite.de@backup.invalid
> 
> Now I tried to redirect mails from my private address sent to anybody
> at charite.de to be redirected to someone else in the organisation,
> like this:
> 
> rxlf.hildebra...@gmail.com REDIRECT toscx.hrn...@charite.de
> 
> Now the following happened: The mails was not sent to the original
> recipient (that was expected), but it also wasn't sent to
> toscx.hrn...@charite.de -- but instead it went the way of the
> always_bcc, but wan't delivered but bounced (according to the logs
> below).

No. The 'redirect' recipient toscx.hrn...@charite.de was bounced.
That is the only recipient that Postfix should attempt to deliver to.

> But in fact it didn't bounce (at least I didn't get anything back).
> 
> Jul 31 09:24:13 mail-cbf-int extern/smtpd[2663640]: NOQUEUE: redirect: RCPT 
> from mail-ej1-f49.google.com[209.85.218.49]: : 
> Sender address triggers REDIRECT toscx.hrn...@charite.de; 
> from= to= 
> proto=ESMTP helo=

> Jul 31 09:24:13 mail-cbf-int extern/smtpd[2663640]: 4WYk9n2SK3z20ycy: 
> client=mail-ej1-f49.google.com[209.85.218.49]
(skipping cleanup header logging)
> Jul 31 09:24:13 mail-cbf-int postfix/qmgr[1615285]: 4WYk9n2SK3z20ycy: 
> from=, size=3810, nrcpt=2 (queue active)
> Jul 31 09:24:13 mail-cbf-int postfix/error[2664442]: 4WYk9n2SK3z20ycy: 
> to=, 
> orig_to=, relay=none, 
> delay=0.62, delays=0.57/0.02/0/0.03, dsn=5.1.1, status=bounced (User unknown)
> Jul 31 09:24:13 mail-cbf-int postfix/qmgr[1615285]: 4WYk9n2SK3z20ycy: removed

Here, the 'redirect' recipient 'toscx.hrn...@charite.de' is bounced.

Is this an unexpanded virtual alias? The 'redirect' recipient is not subject
to canonical mapping, masquerading, or virtual alias mapping.

> Also note that is says "nrcpt=2", but is only being delivered (sort
> of) once. Postfix 3.10-20240724

There were two recipients: the BCC recipient that was found in
recipient_bcc_maps, and the RCPT TO recipient that was used to
search recipient_bcc_maps.

As the queue manager delivers mail, it sorts the recipients, based
on queue, transport, domain, and localpart. Apparently, the BCC
recipient sorted before the RCPT TO recipient.

The queue mamager enforced the redirect once (with the BCC recipient),
and ignored the other address (the RCPT TO recipient).

When the queue manager redirects a recipient, it still logs 'original
recipient' information. Thus, toscx.hrn...@charite.de was logged
with the BCC address as the original recipient. Maybe it should not
log original recipients with redirect, as that could be confusing
when a message has more than one recipient.

> I'm aware that is is some sort of bizarre edge-case.

Let's first see why toscx.hrn...@charite.de' is bounced. 

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


[pfx] Re: always_bcc colliding with access(5) REDIRECT action

2024-07-31 Thread Wietse Venema via Postfix-users
Ralf Hildebrandt via Postfix-users:
> > Jul 31 09:24:13 mail-cbf-int postfix/error[2664442]: 4WYk9n2SK3z20ycy: 
> > to=, 
> > orig_to=, relay=none, 
> > delay=0.62, delays=0.57/0.02/0/0.03, dsn=5.1.1, status=bounced (User 
> > unknown)
> 
> It works, if I replace toscx.hrn...@charite.de with the actual mailbox
> address after address expansion (thrn...@exchange.charite.de)

I thought that the whole point of REDIRECT is to ignore the message
recipients.

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


[pfx] Re: always_bcc colliding with access(5) REDIRECT action

2024-07-31 Thread Ralf Hildebrandt via Postfix-users
> Jul 31 09:24:13 mail-cbf-int postfix/error[2664442]: 4WYk9n2SK3z20ycy: 
> to=, 
> orig_to=, relay=none, 
> delay=0.62, delays=0.57/0.02/0/0.03, dsn=5.1.1, status=bounced (User unknown)

It works, if I replace toscx.hrn...@charite.de with the actual mailbox
address after address expansion (thrn...@exchange.charite.de)

-- 
Ralf Hildebrandt
  Geschäftsbereich IT | Abteilung Netz | Netzwerk-Administration
  Invalidenstraße 120/121 | D-10115 Berlin
  Tel. +49 30 450 570 155 | Fax: +49 30 450 570 962
  ralf.hildebra...@charite.de | https://www.charite.de

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


[pfx] always_bcc colliding with access(5) REDIRECT action

2024-07-31 Thread Ralf Hildebrandt via Postfix-users
We have an always_bcc setup in place for incoming mails:

recipient_bcc_maps = pcre:/etc/postfix/backup_bcc.pcre

/^(.*)@charite\.de$/backup+${1}=charite.de@backup.invalid

Now I tried to redirect mails from my private address sent to anybody
at charite.de to be redirected to someone else in the organisation,
like this:

rxlf.hildebra...@gmail.com REDIRECT toscx.hrn...@charite.de

Now the following happened: The mails was not sent to the original
recipient (that was expected), but it also wasn't sent to
toscx.hrn...@charite.de -- but instead it went the way of the
always_bcc, but wan't delivered but bounced (according to the logs
below).

But in fact it didn't bounce (at least I didn't get anything back).

Jul 31 09:24:13 mail-cbf-int extern/smtpd[2663640]: NOQUEUE: redirect: RCPT 
from mail-ej1-f49.google.com[209.85.218.49]: : 
Sender address triggers REDIRECT toscx.hrn...@charite.de; 
from= to= proto=ESMTP 
helo=
Jul 31 09:24:13 mail-cbf-int extern/smtpd[2663640]: 4WYk9n2SK3z20ycy: 
client=mail-ej1-f49.google.com[209.85.218.49]
Jul 31 09:24:13 mail-cbf-int postfix/cleanup[2659314]: 4WYk9n2SK3z20ycy: info: 
header From: Ralf Hildebrandt  from 
mail-ej1-f49.google.com[209.85.218.49]; from= 
to= proto=ESMTP helo=
Jul 31 09:24:13 mail-cbf-int postfix/cleanup[2659314]: 4WYk9n2SK3z20ycy: info: 
header Date: Wed, 31 Jul 2024 09:24:01 +0200 from 
mail-ej1-f49.google.com[209.85.218.49]; from= 
to= proto=ESMTP helo=
Jul 31 09:24:13 mail-cbf-int postfix/cleanup[2659314]: 4WYk9n2SK3z20ycy: 
message-id=
Jul 31 09:24:13 mail-cbf-int postfix/cleanup[2659314]: 4WYk9n2SK3z20ycy: info: 
header Subject: Test an ralf.hildebra...@charite.de from 
mail-ej1-f49.google.com[209.85.218.49]; from= 
to= proto=ESMTP helo=
Jul 31 09:24:13 mail-cbf-int postfix/cleanup[2659314]: 4WYk9n2SK3z20ycy: info: 
header To: "Ralf Hildebrandt (hildeb)"  from 
mail-ej1-f49.google.com[209.85.218.49]; from= 
to= proto=ESMTP helo=
Jul 31 09:24:13 mail-cbf-int postfix/qmgr[1615285]: 4WYk9n2SK3z20ycy: 
from=, size=3810, nrcpt=2 (queue active)
Jul 31 09:24:13 mail-cbf-int postfix/error[2664442]: 4WYk9n2SK3z20ycy: 
to=, 
orig_to=, relay=none, 
delay=0.62, delays=0.57/0.02/0/0.03, dsn=5.1.1, status=bounced (User unknown)
Jul 31 09:24:13 mail-cbf-int postfix/qmgr[1615285]: 4WYk9n2SK3z20ycy: removed

Also note that is says "nrcpt=2", but is only being delivered (sort
of) once. Postfix 3.10-20240724

I'm aware that is is some sort of bizarre edge-case.

-- 
Ralf Hildebrandt
  Geschäftsbereich IT | Abteilung Netz | Netzwerk-Administration
  Invalidenstraße 120/121 | D-10115 Berlin
  Tel. +49 30 450 570 155 | Fax: +49 30 450 570 962
  ralf.hildebra...@charite.de | https://www.charite.de

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


[pfx] Re: Mail archival like with always_bcc, but different BCC destinations by virtual mailbox domains

2023-07-16 Thread Wietse Venema via Postfix-users
r.barclay--- via Postfix-users:
> Hello,
> 
> I have a Postfix installation for virtual mailboxes. It is the
> mail server (inbound MX and outbound) for a few domains. The server
> allows submission with SMTP AUTH (Dovecot SASL).
>
> At the moment I use always_bcc to "copy" / mirror any inbound AND
> outbound emails into an archive maildir. It's only one central
> archive maildir for all inbound and outbound mails of all virtual
> mailboxes.
>
> What approach would you use if you wanted different archive bcc
> mailboxes depending on the virtual domain?

https://www.postfix.org/postconf.5.html#recipient_bcc_maps
https://www.postfix.org/postconf.5.html#sender_bcc_maps

When a user sends mail from and to their virtual domain, the duplicate
BCC address will be taken care of by a built-in filter
(https://www.postfix.org/postconf.5.html#duplicate_filter_limit).

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


[pfx] Mail archival like with always_bcc, but different BCC destinations by virtual mailbox domains

2023-07-16 Thread r.barclay--- via Postfix-users
Hello,

I have a Postfix installation for virtual mailboxes. It is the mail server 
(inbound MX and outbound) for a few domains. The server allows submission with 
SMTP AUTH (Dovecot SASL).

At the moment I use always_bcc to "copy" / mirror any inbound AND outbound 
emails into an archive maildir. It's only one central archive maildir for all 
inbound and outbound mails of all virtual mailboxes.

What approach would you use if you wanted different archive bcc mailboxes 
depending on the virtual domain?

Example:
- Postfix is mailserver for example-a.com / example-a.net and example-b.com / 
example-b.net.
- Mails sent TO and BY example-a.com / example-a.net mailboxes go to 
archive.A@localhost
- Mails sent TO and BY example-b.com / example-b.net mailboxes go to 
archive.B@localhost

I guess, for INBOUND I might be able to use virtual_alias_maps like this:

u...@example-a.com -> \u...@example-a.com, archive.A@localhost
u...@example-b.com -> \u...@example-b.com, archive.B@localhost

But what about mails that are SENT BY u...@example-a.com to (external) 
mailboxes?

How could one capture the outbound mails as well? Separated based on the sender 
virtual domain?

Or one dedicated archive maildir for each virtual mailbox would be fine, as 
well. Actually even better!

Or in general, what approaches do you use with Postfix for mailbox archival?
In the best case something based on Postfix configuration, or in the second 
best case something based on other open source software? Maybe some kind of 
milter?

Would this work: Define a transport that invoked "myarchivalscript.sh" for any 
incoming mail to "@archival.local" and then use "archival@archival.local" in 
"always_bcc" and let the script decide on where to store an email copy?

Thanks for your ideas and hints!
Reg

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


Re: always_bcc to multiple recipients

2023-02-12 Thread Arrigo Triulzi
On 12 Feb 2023, at 17:53, Wietse Venema  wrote:
> To bcc to multiple recipients with existing Postfix versions, specify
> one address with always_bcc (or sender_bcc_maps or recipient_bcc_maps),
> and expand that into multiple recipients using virtual_alias_maps.

Right, so this matches what I thought would work.

> To avoid repeated expansions and repeated spam filters, look for
> receive_override_options in https://www.postfix.org/FILTER_README.html.

Thank you for this.

Cheers,

Arrigo 



Re: always_bcc to multiple recipients

2023-02-12 Thread Wietse Venema
Arrigo Triulzi:
> Hi,
> 
> I was wondering what, if any, is the recommendation on how to have
> multiple recipients for always_bcc.

always_bcc accepts one recipient (as do sender_bcc_maps and
recipient_bcc_maps). Fixing that would require new code (I have
added this as a WISHLIST item).

To bcc to multiple recipients with existing Postfix versions, specify
one address with always_bcc (or sender_bcc_maps or recipient_bcc_maps),
and expand that into multiple recipients using virtual_alias_maps.

virtual alias expansion should propagate the "NOTIFY=NONE" property
to the result of alias expansion.

> I was thinking of using something like alias@localhost and then
> expanding it but I am concerned that it will go through mail filters
> (amavisd-new in my case) multiple times.
> 
> Any recommendations or alternatives appreciated.

To avoid repeated expansions and repeated spam filters, look for
receive_override_options in https://www.postfix.org/FILTER_README.html.

Wietse


always_bcc to multiple recipients

2023-02-12 Thread Arrigo Triulzi
Hi,

I was wondering what, if any, is the recommendation on how to have multiple 
recipients for always_bcc.  

I was thinking of using something like alias@localhost and then expanding it 
but I am concerned that it will go through mail filters (amavisd-new in my 
case) multiple times.

Any recommendations or alternatives appreciated.

Cheers,

Arrigo 



Re: Duplicate message delivery to always_bcc with dovecot and Simple Content Filter (Postfix)

2022-12-20 Thread Yanko Hernández Álvarez
On Tue, Dec 20, 2022 at 9:46 AM Yanko Hernández Álvarez
 wrote:
>
> That's a good one
>
> It seems possible. Let me check. The problem is the ldap query now.
> I'm not sure if I can do that with ldap. mailfilter does two ldap
> queries, one to lookup the "main" group/role and another to get the
> email address of that role. Kind of a sql join, but in two parts. Let
> me see if I can do it with one query. Or maybe change how this data is
> stored inside the ldap db.
>
> But good catch!!! I learned something new today!!!
>
> Thanks!
>

Well, it seems ldap queries are not flexible enough. It's a shame.


Re: Duplicate message delivery to always_bcc with dovecot and Simple Content Filter (Postfix)

2022-12-20 Thread Yanko Hernández Álvarez
That's a good one

It seems possible. Let me check. The problem is the ldap query now.
I'm not sure if I can do that with ldap. mailfilter does two ldap
queries, one to lookup the "main" group/role and another to get the
email address of that role. Kind of a sql join, but in two parts. Let
me see if I can do it with one query. Or maybe change how this data is
stored inside the ldap db.

But good catch!!! I learned something new today!!!

Thanks!

On Tue, Dec 20, 2022 at 5:04 AM raf  wrote:
>
> On Mon, Dec 19, 2022 at 12:21:02PM -0500, Yanko Hernández Álvarez 
>  wrote:
>
> > On Mon, Dec 19, 2022 at 11:36 AM Matus UHLAR - fantomas
> >  wrote:
> > > >#!/bin/sh
> > > >
> > > >/usr/bin/cat | /var/spool/filter/scripts/mailfilter |
> > > >/usr/sbin/sendmail -G -i "$@"
> > > >
> > > >exit $?
> > >
> > > this means that the always_bcc is executed again.
> > > usually the content_filter is supposed to inject mail on alternative port
> > > where option:
> > > receive_override_options = no_address_mappings
> > >
> > > is used: see http://www.postfix.org/FILTER_README.html
> > >
> >
> > Yes, I'm aware of that, but I was trying not to use the advanced filter.
> >
> > In the end it seems that there is no alternative to the advanced
> > filter. But I'm asking here in case I overlooked something or
> > misunderstood something.
>
> Perhaps I'm mistaken, but it sounds like mailfilter
> could be replaced with canonical addressing to rewrite
> sender addresses in outgoing emails.
>
>   http://www.postfix.org/ADDRESS_REWRITING_README.html#canonical
>
> If so, it might simplify things.
>
> cheers,
> raf
>


Re: Duplicate message delivery to always_bcc with dovecot and Simple Content Filter (Postfix)

2022-12-20 Thread raf
On Mon, Dec 19, 2022 at 12:21:02PM -0500, Yanko Hernández Álvarez 
 wrote:

> On Mon, Dec 19, 2022 at 11:36 AM Matus UHLAR - fantomas
>  wrote:
> > >#!/bin/sh
> > >
> > >/usr/bin/cat | /var/spool/filter/scripts/mailfilter |
> > >/usr/sbin/sendmail -G -i "$@"
> > >
> > >exit $?
> >
> > this means that the always_bcc is executed again.
> > usually the content_filter is supposed to inject mail on alternative port
> > where option:
> > receive_override_options = no_address_mappings
> >
> > is used: see http://www.postfix.org/FILTER_README.html
> >
> 
> Yes, I'm aware of that, but I was trying not to use the advanced filter.
> 
> In the end it seems that there is no alternative to the advanced
> filter. But I'm asking here in case I overlooked something or
> misunderstood something.

Perhaps I'm mistaken, but it sounds like mailfilter
could be replaced with canonical addressing to rewrite
sender addresses in outgoing emails.

  http://www.postfix.org/ADDRESS_REWRITING_README.html#canonical

If so, it might simplify things.

cheers,
raf



Re: Duplicate message delivery to always_bcc with dovecot and Simple Content Filter (Postfix)

2022-12-19 Thread Yanko Hernández Álvarez
On Mon, Dec 19, 2022 at 11:36 AM Matus UHLAR - fantomas
 wrote:
> >#!/bin/sh
> >
> >/usr/bin/cat | /var/spool/filter/scripts/mailfilter |
> >/usr/sbin/sendmail -G -i "$@"
> >
> >exit $?
>
> this means that the always_bcc is executed again.
> usually the content_filter is supposed to inject mail on alternative port
> where option:
> receive_override_options = no_address_mappings
>
> is used: see http://www.postfix.org/FILTER_README.html
>

Yes, I'm aware of that, but I was trying not to use the advanced filter.

In the end it seems that there is no alternative to the advanced
filter. But I'm asking here in case I overlooked something or
misunderstood something.


Re: Duplicate message delivery to always_bcc with dovecot and Simple Content Filter (Postfix)

2022-12-19 Thread Jaroslaw Rafa
Dnia 19.12.2022 o godz. 11:00:38 Yanko Hernández Álvarez pisze:
> 
> The problem is, when I send an email, it delivers two copies to
> seccopies@mydomain.example as seen in the logs, not one copy as
> expected.
[...]
> Any idea of how I can fix it?

Bear in mind that when you use a post-queue content filter, *two* delivery
cycles are made per each email (before filter and after filter). During each
delivery a copy is sent to always_bcc. That's why you get two copies.

The best method (although maybe not simplest, in terms of coding) to fix
this is to replace after-queue filtering with before-queue filtering, ie.
you should change your filter script into a milter. With milters, there will
be only one delivery cycle per message.
-- 
Regards,
   Jaroslaw Rafa
   r...@rafa.eu.org
--
"In a million years, when kids go to school, they're gonna know: once there
was a Hushpuppy, and she lived with her daddy in the Bathtub."


Re: Duplicate message delivery to always_bcc with dovecot and Simple Content Filter (Postfix)

2022-12-19 Thread Matus UHLAR - fantomas

On 19.12.22 11:00, Yanko Hernández Álvarez wrote:

Well, from reading the subject I feel I made an obvious mistake and I
lost something when I read the documentation. I asked many people and
tried ServerFault to no avail and I'm tired of banging my head against
the wall.

I'm trying to set up a very low traffic postfix mail server using:

- A Simple content filter
(http://www.postfix.org/FILTER_README.html#simple_filter). It's way
simpler than the advanced one and the traffic is low.
- dovecot as a delivery agent. (Because of maildir quotas and sieve filters)
- `always_bcc` to keep copies of every mail sent. (Bussiness rules)



   #!/bin/sh

   /usr/bin/cat | /var/spool/filter/scripts/mailfilter |
/usr/sbin/sendmail -G -i "$@"

   exit $?


this means that the always_bcc is executed again.
usually the content_filter is supposed to inject mail on alternative port 
where option:

receive_override_options = no_address_mappings

is used: see http://www.postfix.org/FILTER_README.html

--
Matus UHLAR - fantomas, uh...@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
Remember half the people you know are below average.


Duplicate message delivery to always_bcc with dovecot and Simple Content Filter (Postfix)

2022-12-19 Thread Yanko Hernández Álvarez
Well, from reading the subject I feel I made an obvious mistake and I
lost something when I read the documentation. I asked many people and
tried ServerFault to no avail and I'm tired of banging my head against
the wall.

I'm trying to set up a very low traffic postfix mail server using:

- A Simple content filter
(http://www.postfix.org/FILTER_README.html#simple_filter). It's way
simpler than the advanced one and the traffic is low.
- dovecot as a delivery agent. (Because of maildir quotas and sieve filters)
- `always_bcc` to keep copies of every mail sent. (Bussiness rules)

My relevant configs are:

master.cf
--

smtp  inet  n   -   y   -   -   smtpd
-o content_filter=filter:dummy
pickupunix  n   -   y   60  1   pickup
cleanup   unix  n   -   y   -   0   cleanup
qmgr  unix  n   -   n   300 1   qmgr
tlsmgrunix  -   -   y   1000?   1   tlsmgr
rewrite   unix  -   -   y   -   -   trivial-rewrite
bounceunix  -   -   y   -   0   bounce
defer unix  -   -   y   -   0   bounce
trace unix  -   -   y   -   0   bounce
verifyunix  -   -   y   -   1   verify
flush unix  n   -   y   1000?   0   flush
proxymap  unix  -   -   n   -   -   proxymap
proxywrite unix -   -   n   -   1   proxymap
smtp  unix  -   -   y   -   -   smtp
relay unix  -   -   y   -   -   smtp
-o syslog_name=postfix/$service_name
showq unix  n   -   y   -   -   showq
error unix  -   -   y   -   -   error
retry unix  -   -   y   -   -   error
discard   unix  -   -   y   -   -   discard
local unix  -   n   n   -   -   local
virtual   unix  -   n   n   -   -   virtual
lmtp  unix  -   -   y   -   -   lmtp
anvil unix  -   -   y   -   1   anvil
scacheunix  -   -   y   -   1   scache
postlog   unix-dgram n  -   n   -   1   postlogd
uucp  unix  -   n   n   -   -   pipe
  flags=Fqhu user=uucp argv=uux -r -n -z -a$sender -
$nexthop!rmail ($recipient)
filterunix  -   n   n   -   10  pipe
  flags=Rq user=filter null_sender=
  argv=/var/spool/filter/scripts/filter.sh -f ${sender} -- ${recipient}
dovecotunix  -   n   n   -   -   pipe
  flags=DRhu user=vmail:mail argv=/usr/lib/dovecot/dovecot-lda -f
${sender} -d ${recipient}


--

main.cf (relevant parts only)
--

always_bcc = seccopies@mydomain.example
virtual_transport = dovecot
dovecot_destination_recipient_limit = 1

--

/var/spool/filter/scripts/filter.sh
--

#!/bin/sh

/usr/bin/cat | /var/spool/filter/scripts/mailfilter |
/usr/sbin/sendmail -G -i "$@"

exit $?

--

- All my users have emails in "(Initial).surname@mydomain.example" format
- There are security groups that act as roles and each one has emails
in "role@mydomain.example" format.
- Basically, a role email function as an alias to several users.

So, I can reuse the same Roles/Groups I use to set permissions, and
not using the users directly.

For example
- my user email is y.hernandez@mydomain.example
- I'm a member of role I.T.Department (informatics@mydomain.example)
- I'm a member of some other roles, but my main role is "I.T.Department"
- Because I'm a member of this group/role I have certain privileges,
as the other members and every mail sent to
informatics@mydomain.example will reach me and the other members.

So far, so good... But my boss wants that every mail I send uses the
informatics@mydomain.example (role) address instead of
y.hernandez@mydomain.example (user). i.e., that every mail sent uses
the principal role email, not the user email.

`/var/spool/filter/scripts/mailfilter` is an in-house made filter that
just does that (changes "from" addresses from "(Initial).surname@" to
"role@" checking an LDAP server).

It never fails (In case of any error condition, it just copies
standard input into standard output and no modification is made, so no
address change, but the mail is not lost).

The problem is, when I send an email, it delivers two copies to
seccopies@mydomain.example as seen in the logs, not one copy as
expected.

--

Dec 16 16:23:08 correo2 postfix/smtpd[32453]: connect from
informatica1.mydomain.example[10.128.159.15]
Dec 16 16:23:08 correo2 postfix/smtpd[32453]

Re: Postfix with "always_bcc" email is 2x or 3x on the always_bcc mail

2022-10-11 Thread Josef Karliak



  Hi Wietse,

  thank you for your help, all works fine.

  Best regards

  J.Karliak

Dne 2022-10-11 11:45, Wietse Venema napsal:


Josef Karliak:


Good morning,

what could cause the mail copied by postfix's always_bcc -  copied
email is 2x or sometimes (?) 3x copied in the always_bcc email.

I use DKIM and DMARC milter and Spamassasisn as a
"check_policy_service". Could the passing to the milters cause it ?


No. See https://www.postfix.org/FILTER_README.html for suggestions
to set "receive_override_options=no_address_mappings" in master.cf
to avoid multiple bcc recipients.

Wietse

Re: Postfix with "always_bcc" email is 2x or 3x on the always_bcc mail

2022-10-11 Thread Wietse Venema
Josef Karliak:
> 
> 
>Good morning,
> 
>what could cause the mail copied by postfix's always_bcc -  copied 
> email is 2x or sometimes (?) 3x copied in the always_bcc email.
> 
>I use DKIM and DMARC milter and Spamassasisn as a 
> "check_policy_service". Could the passing to the milters cause it ?

No. See https://www.postfix.org/FILTER_README.html for suggestions
to set "receive_override_options=no_address_mappings" in master.cf
to avoid multiple bcc recipients.

Wietse


Postfix with "always_bcc" email is 2x or 3x on the always_bcc mail

2022-10-10 Thread Josef Karliak



  Good morning,

  what could cause the mail copied by postfix's always_bcc -  copied 
email is 2x or sometimes (?) 3x copied in the always_bcc email.


  I use DKIM and DMARC milter and Spamassasisn as a 
"check_policy_service". Could the passing to the milters cause it ?


  Thanks and best regards

  J.Karliak

Re: always_bcc for selected recipients? map support?

2022-04-14 Thread PGNet Dev

Try sender_bcc_maps or recipient_bcc_maps.


once again, looking in the wrong place!

perfect, thx.


Re: always_bcc for selected recipients? map support?

2022-04-14 Thread Wietse Venema
PGNet Dev:
> I'd like to have my Postfix receiving instance always bcc mail for a specific 
> set of recipients to another , off-site server.
> And to do so regardless of the intended 'main' recipient address being 'up' 
> for receiving @ subsequent Postfix transport delivery targets, or not.
> 
> Reading,
> 
>   https://www.postfix.org/postconf.5.html#always_bcc
> 
> straightforward for bcc'ing all.
> 
> But I don't immediately see that it support maps.

Try sender_bcc_maps or recipient_bcc_maps.

Wietse


Re: always_bcc for selected recipients? map support?

2022-04-14 Thread Benny Pedersen

On 2022-04-14 19:19, PGNet Dev wrote:


https://www.postfix.org/postconf.5.html#always_bcc

straightforward for bcc'ing all.

But I don't immediately see that it support maps.


maps what ?


(1) does always_bcc support maps? (doc or example?)

(2) is there a better alternative that always_bcc for this use?


maybe use recipient_bcc ?

or sender_bcc ?

or combination of all

messy :)


always_bcc for selected recipients? map support?

2022-04-14 Thread PGNet Dev

I'd like to have my Postfix receiving instance always bcc mail for a specific 
set of recipients to another , off-site server.
And to do so regardless of the intended 'main' recipient address being 'up' for 
receiving @ subsequent Postfix transport delivery targets, or not.

Reading,

https://www.postfix.org/postconf.5.html#always_bcc

straightforward for bcc'ing all.

But I don't immediately see that it support maps.

(1) does always_bcc support maps? (doc or example?)

(2) is there a better alternative that always_bcc for this use?


Re: multi instance and always_bcc

2022-01-10 Thread Viktor Dukhovni
> On 11 Jan 2022, at 3:43 am, Wietse Venema  wrote:
> 
> Recipients added with always_bcc, xxx_bcc_maps, etc., are treated
> just like any other recipients. All recipients are subject to
> content_filter, relayhost, etc.

Fortunately, they're also subject to transport table lookups,
so it is fairly simple to arrange to route these differently...

-- 
Viktor.



Re: multi instance and always_bcc

2022-01-10 Thread Wietse Venema
Zsombor B:
> Hi,
> 
> 
> 
> We'd like to debug some emails sent through a multi instance withouth 
> having any impact on the mail flow so I have added 
> always_bcc=de...@whatever.com to the main.cf of that instance and 
> reloaded it.
> 
> But instead of sending copies of the emails to the debug address, 
> postfix relays both the original and the bcc emails to the relayhost of 
> the multi instance as well.
> 
> This is postfix v3.2.10 on a SLES 12 SP5 server.
> 
> Is this the expected behaviour?

Recipients added with always_bcc, xxx_bcc_maps, etc., are treated
just like any other recipients. All recipients are subject to
content_filter, relayhost, etc.

Wietse


Re: multi instance and always_bcc

2022-01-10 Thread Dominic Raferd

My understanding is that always_bcc does not work:
- if receive_override_options includes no_address_mappings; or
- after Postfix has forwarded mail internally; or
- for mails generated by Postfix itself

On 10/01/2022 16:28, Zsombor B wrote:

We'd like to debug some emails sent through a multi instance withouth
having any impact on the mail flow so I have added
always_bcc=de...@whatever.com to the main.cf of that instance and
reloaded it.

But instead of sending copies of the emails to the debug address,
postfix relays both the original and the bcc emails to the relayhost of
the multi instance as well.

This is postfix v3.2.10 on a SLES 12 SP5 server.

Is this the expected behaviour?


multi instance and always_bcc

2022-01-10 Thread Zsombor B

Hi,



We'd like to debug some emails sent through a multi instance withouth 
having any impact on the mail flow so I have added 
always_bcc=de...@whatever.com to the main.cf of that instance and 
reloaded it.


But instead of sending copies of the emails to the debug address, 
postfix relays both the original and the bcc emails to the relayhost of 
the multi instance as well.


This is postfix v3.2.10 on a SLES 12 SP5 server.

Is this the expected behaviour?


Thanks,
Zsombor


Re: REDIRECT overrides always_bcc

2021-06-15 Thread Dominic Raferd

On 20/04/2021 10:04, Matus UHLAR - fantomas wrote:

On 2021-04-16 12:03, Dominic Raferd wrote:
> I have started using a REDIRECT action in a header_checks table
> which works but seems to prevent always_bcc from operating -
> the email is not bcc'd.



On Fri, 16 Apr 2021, 20:07 Rob McGee,  wrote:

It's ugly, but a possible workaround: REDIRECT to an address which
runs a script (transport_maps entry to a pipe(8) or to a local(8)
address with a ~/.forward), and the script delivers a copy to your
BCC address by some means.


On 19.04.21 21:47, Dominic Raferd wrote:

Thanks for this suggestion, I might well implement it


which reminds me, I have simply added the address in always_bcc to an 
alias

where such mail is redirected.


Rather late I have tried this and it works perfectly - thanks.


Re: Re: Use both recipient_bcc_maps and always_bcc

2021-05-31 Thread r . barclay
Matus and Viktor, thank you for your responses!

I'm trying to add an additional BCC for some mail recipients but not for all.
All mails must go into the archive (always_bcc). This works so far.
But now, for some recipients, I'd like to have an additional BCC. So 
recipient_bcc_maps seems to be what I'm looking for.

The reason behind this: I have to process the mails to *some* recipients with a 
custom written program using "pipe" transport - but *additional* to Spam and 
Virus filtering (Amavis), mail archival (always_bcc) and normal delivery (LMTP 
/ Dovecot). I also thought about monitoring the affected Maildirs for changes 
(inotify). But I want the program based processing take place independently 
from what happens in the mailbox (deletion or moving of mails). The program 
should not fail if a user deletes a message faster than my program processed 
it. So I abandoned the Maildir monitoring approach.


> Gesendet: Montag, 31. Mai 2021 um 10:26 Uhr
> Von: "Viktor Dukhovni" 
> An: postfix-users@postfix.org
> Betreff: Re: Use both recipient_bcc_maps and always_bcc
>
> On Mon, May 31, 2021 at 10:07:13AM +0200, r.barc...@habmalnefrage.de wrote:
>
> > I use the "always_bcc" option to collect all emails for a local email 
> > archive.
> >
> > Can one use recipient_bcc_maps in addition to that?
> >
> > So I could make emails to "u...@example.org" go into the archive 
> > (always_bcc) and also to another BCC address defined through 
> > recipient_bcc_maps?
> >
> > In the mailing list on Oct 27, 2016; 8:29am, Wietse wrote concerning 
> > recipient_bcc_maps:
> > "As documented, you can't specify multiple addresses on the right-hand 
> > side."
> >
> > So recipient_bcc_maps could not define more than 1 address.
> > But would 2 addresses work using a combination of always_bcc AND 
> > recipient_bcc_maps?
> > Or does one of these options render the other one unusable?
>
> Methinkgs you're working too hard, ...  Why not just use virtual(5) to
> rewrite the configured logical BCC address(es) to whatever underlying
> list of recipients you want?
>
> --
> Viktor.
>


Re: Use both recipient_bcc_maps and always_bcc

2021-05-31 Thread Viktor Dukhovni
On Mon, May 31, 2021 at 10:07:13AM +0200, r.barc...@habmalnefrage.de wrote:

> I use the "always_bcc" option to collect all emails for a local email archive.
> 
> Can one use recipient_bcc_maps in addition to that?
> 
> So I could make emails to "u...@example.org" go into the archive (always_bcc) 
> and also to another BCC address defined through recipient_bcc_maps?
> 
> In the mailing list on Oct 27, 2016; 8:29am, Wietse wrote concerning 
> recipient_bcc_maps:
> "As documented, you can't specify multiple addresses on the right-hand side."
> 
> So recipient_bcc_maps could not define more than 1 address.
> But would 2 addresses work using a combination of always_bcc AND 
> recipient_bcc_maps?
> Or does one of these options render the other one unusable?

Methinkgs you're working too hard, ...  Why not just use virtual(5) to
rewrite the configured logical BCC address(es) to whatever underlying
list of recipients you want?

-- 
Viktor.


Re: Use both recipient_bcc_maps and always_bcc

2021-05-31 Thread Matus UHLAR - fantomas

On 31.05.21 10:07, r.barc...@habmalnefrage.de wrote:

I use the "always_bcc" option to collect all emails for a local email archive.

Can one use recipient_bcc_maps in addition to that?


this worked here iirc.


So I could make emails to "u...@example.org" go into the archive (always_bcc) 
and also to another BCC address defined through recipient_bcc_maps?

In the mailing list on Oct 27, 2016; 8:29am, Wietse wrote concerning 
recipient_bcc_maps:
"As documented, you can't specify multiple addresses on the right-hand side."

So recipient_bcc_maps could not define more than 1 address.
But would 2 addresses work using a combination of always_bcc AND 
recipient_bcc_maps?
Or does one of these options render the other one unusable?

--
Matus UHLAR - fantomas, uh...@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
Spam is for losers who can't get business any other way.


Use both recipient_bcc_maps and always_bcc

2021-05-31 Thread r . barclay
Hello!

I use the "always_bcc" option to collect all emails for a local email archive.

Can one use recipient_bcc_maps in addition to that?

So I could make emails to "u...@example.org" go into the archive (always_bcc) 
and also to another BCC address defined through recipient_bcc_maps?

In the mailing list on Oct 27, 2016; 8:29am, Wietse wrote concerning 
recipient_bcc_maps:
"As documented, you can't specify multiple addresses on the right-hand side."

So recipient_bcc_maps could not define more than 1 address.
But would 2 addresses work using a combination of always_bcc AND 
recipient_bcc_maps?
Or does one of these options render the other one unusable?

Thanks a lot!

Kind regards,
Reg


Re: Configuring always_bcc

2021-04-22 Thread Matus UHLAR - fantomas

>> > receive_override_options = no_address_mappings
>> >
>> > and then permit mappings (which include always_bcc) to occur in the 2nd
>> > instance (for the mail that is returned by amavis), for example this
>> > might be in master.cf by:
>> >
>> > 127.0.0.1:10025 inet n   -   n   -   -   smtpd
>> ># note: absence of no_address_mappings means that address mapping
>> > *will* occur here, including always_bcc
>> >-o receive_override_options=no_unknown_recipient_checks,no_milters
>> >...


On 21.04.21 15:29, Alex wrote:

I should have made that more clear. The problem is that I'm trying to
create an address to which amavisd should forward all mail unfiltered,
but it only works if either all addresses are included in the policy
or the unfiltered address is the only address. For example:

@spam_lovers_maps = ( ['a...@example.com'] );
@bypass_spam_checks_maps = ( ['a...@example.com'] );

Also, we have a set of scripts that parse the log output and it's
being impacted by this bcc-user address. This also means that any mail
quarantined by amavisd for the recipient is also quarantined for the
bcc-user.


you CAN do this, bot for this, you must do EXACTLY what I have written
before:


I recomment doing no_address_mappings on port 10025 when receiving mail from
amavis, and not globally in the main.cf.

*recommend of course.

because is it NOT possible to deliver unchanged mail to always_bcc address,
when the always_bcc happens AFTER the mail is changed.


--
Matus UHLAR - fantomas, uh...@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
Spam is for losers who can't get business any other way.


Re: Configuring always_bcc

2021-04-21 Thread Alex
Hi,

> > > > I thought I said transport...
> > >
> > > Postfix instance 1
> > >
> > > main.cf
> > > always_bcc = f...@example.com
> > >
> > > transport_maps
> > > f...@example.com -> Postfix instance 2
> > > all other mail -> content filter -> Postfix instance 2
> > >
> > > Perhaps a picture is worth 1e3 words.
> >
> > Does this mean modifying my existing default_transport to send mail to
> > be filtered through a transport instead?
>
> No, it means a transport(5) table entry for special-casing
> the BCC recipients.

Somehow I was confusing transports with transport maps.

> You leave your default transport alone, it is used for normal
> recipients.  You route the BCC recipients via the transport
> table.

Now I understand. I've used transport maps a dozen times before but
never thought about it this way.

> Some explanation would help to understand which instance receives new mail, 
> which instances send into and receive from filter, and why you need three 
> instances.

I created multiple instances to assign each one to a different IP for
different domains to be able to associate their domain with separate
MX records and separate body/header checks, etc.

Thanks so much,
Alex


Re: Configuring always_bcc

2021-04-21 Thread Viktor Dukhovni
On Wed, Apr 21, 2021 at 04:19:52PM -0400, Alex wrote:

> > > I thought I said transport...
> >
> > Postfix instance 1
> >
> > main.cf
> > always_bcc = f...@example.com
> >
> > transport_maps
> > f...@example.com -> Postfix instance 2
> > all other mail -> content filter -> Postfix instance 2
> >
> > Perhaps a picture is worth 1e3 words.
> 
> Does this mean modifying my existing default_transport to send mail to
> be filtered through a transport instead?

No, it means a transport(5) table entry for special-casing
the BCC recipients.

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

transport:
# A single Bcc recipient
b...@example.com relay:[wherever]:someport

# And/or a dedicated domain for Bcc recipients
bcc.example.com relay:[wherever]:someport

> # postconf -c /etc/postfix-117 default_transport
> default_transport = smtp:[127.0.0.1]:10024
> 
> And this is a separate solution from Victor's, correct?

You leave your default transport alone, it is used for normal
recipients.  You route the BCC recipients via the transport
table.

-- 
Viktor.


Re: Configuring always_bcc

2021-04-21 Thread Wietse Venema
Alex:
> > It is more or less Viktor's suggestion.
> >
> > Some details will be missing: relay_domains needs to be set u so
> > that Postfix instance 1 won't reject mail with "relay access denied".
> 
> Thanks for sticking with me here. That's a pretty big change for me.
> Victor helped me create the multi-instance setup initially, but I
> don't understand enough to set up the transports in this way.
> mydestination and virtual_mailbox_domains are empty.
> 
> # postmulti -l
> -   -   y /etc/postfix
> postfix-out mta y /etc/postfix-out
> postfix-109 mta y /etc/postfix-109
> postfix-110 mta y /etc/postfix-110
> 
> # postconf -nc /etc/postfix-109 |grep transport
> default_transport = smtp:[127.0.0.1]:10024
> local_transport = error:5.1.1 Mailbox unavailable
> relay_transport = $default_transport
> transport_maps =

Does this need a transport map to route the bcc recipient
around the filter?

> virtual_transport = $default_transport

Some explanation would help to understand which instance receives
new mail, which instances send into and receive from filter, and
why you need three instances.

Wietse


Re: Configuring always_bcc

2021-04-21 Thread Alex
Hi,

> Wietse:
> > Postfix instance 1
> >
> > main.cf
> > always_bcc = f...@example.com
> >
> > transport_maps
> > f...@example.com -> Postfix instance 2
> > all other mail -> content filter -> Postfix instance 2
> >
> > Perhaps a picture is worth 1e3 words.
>
> Alex:
> > Does this mean modifying my existing default_transport to send mail to
> > be filtered through a transport instead?
> >
> > # postconf -c /etc/postfix-117 default_transport
> > default_transport = smtp:[127.0.0.1]:10024
>
> That will work, assuming that Postfix instance 1 does not try to
> make its own final deliveries (i.e. mydestination is smpty, ditto
> for virtual_mailbox_domains).
>
> > And this is a separate solution from Victor's, correct?
>
> It is more or less Viktor's suggestion.
>
> Some details will be missing: relay_domains needs to be set u so
> that Postfix instance 1 won't reject mail with "relay access denied".

Thanks for sticking with me here. That's a pretty big change for me.
Victor helped me create the multi-instance setup initially, but I
don't understand enough to set up the transports in this way.
mydestination and virtual_mailbox_domains are empty.

# postmulti -l
-   -   y /etc/postfix
postfix-out mta y /etc/postfix-out
postfix-109 mta y /etc/postfix-109
postfix-110 mta y /etc/postfix-110

# postconf -nc /etc/postfix-109 |grep transport
default_transport = smtp:[127.0.0.1]:10024
local_transport = error:5.1.1 Mailbox unavailable
relay_transport = $default_transport
transport_maps =
virtual_transport = $default_transport


Re: Configuring always_bcc

2021-04-21 Thread Wietse Venema
Wietse:
> Postfix instance 1
>
> main.cf
>     always_bcc = f...@example.com
>
> transport_maps
> f...@example.com -> Postfix instance 2
> all other mail -> content filter -> Postfix instance 2
>
> Perhaps a picture is worth 1e3 words.

Alex:
> Does this mean modifying my existing default_transport to send mail to
> be filtered through a transport instead?
> 
> # postconf -c /etc/postfix-117 default_transport
> default_transport = smtp:[127.0.0.1]:10024

That will work, assuming that Postfix instance 1 does not try to
make its own final deliveries (i.e. mydestination is smpty, ditto
for virtual_mailbox_domains).

> And this is a separate solution from Victor's, correct?

It is more or less Viktor's suggestion. 

Some details will be missing: relay_domains needs to be set u so
that Postfix instance 1 won't reject mail with "relay access denied".

Wietse


Re: Configuring always_bcc

2021-04-21 Thread Alex
> > > I'm currently using the default_transport to route mail to 10025 for
> > > amavisd. Would I then just use the local transport for local mail then
> > > define it in the transport file?
> >
> > No, because presumably the Bcc mail is supposed to be delivered
> > somewhere else via SMTP.  Instead, you would use a separate logical
> > domain for Bcc recipients, and route that domain (via a suitable
> > transport table entry) to a separate transport (perhaps bypass amavis
> > entirely, unless you need amavis to do something special with Bcc mail).
> >
> > > Or perhaps local_recipient_maps? mydestination is not currently
> > > defined for this instance.
> >
> > I thought I said transport...
>
> Postfix instance 1
>
> main.cf
> always_bcc = f...@example.com
>
> transport_maps
> f...@example.com -> Postfix instance 2
> all other mail -> content filter -> Postfix instance 2
>
> Perhaps a picture is worth 1e3 words.

Does this mean modifying my existing default_transport to send mail to
be filtered through a transport instead?

# postconf -c /etc/postfix-117 default_transport
default_transport = smtp:[127.0.0.1]:10024

And this is a separate solution from Victor's, correct?


Re: Configuring always_bcc

2021-04-21 Thread Wietse Venema
Viktor Dukhovni:
> On Wed, Apr 21, 2021 at 03:53:34PM -0400, Alex wrote:
> 
> > > This is why you have a multi-instance configuration.  You can use the
> > > transport table to selectively route specific recipients to specific
> > > filter transports, ... by avoiding content_filter and using normal
> > > Postfix transport-based routing.  This requires separate pre and
> > > post filter queues, which is what multiple instances give you.
> > 
> > I'm currently using the default_transport to route mail to 10025 for
> > amavisd. Would I then just use the local transport for local mail then
> > define it in the transport file?
> 
> No, because presumably the Bcc mail is supposed to be delivered
> somewhere else via SMTP.  Instead, you would use a separate logical
> domain for Bcc recipients, and route that domain (via a suitable
> transport table entry) to a separate transport (perhaps bypass amavis
> entirely, unless you need amavis to do something special with Bcc mail).
> 
> > Or perhaps local_recipient_maps? mydestination is not currently
> > defined for this instance.
> 
> I thought I said transport...

Postfix instance 1

main.cf
always_bcc = f...@example.com

transport_maps
f...@example.com -> Postfix instance 2
all other mail -> content filter -> Postfix instance 2

Perhaps a picture is worth 1e3 words.

Wietse


Re: Configuring always_bcc

2021-04-21 Thread Viktor Dukhovni
On Wed, Apr 21, 2021 at 03:53:34PM -0400, Alex wrote:

> > This is why you have a multi-instance configuration.  You can use the
> > transport table to selectively route specific recipients to specific
> > filter transports, ... by avoiding content_filter and using normal
> > Postfix transport-based routing.  This requires separate pre and
> > post filter queues, which is what multiple instances give you.
> 
> I'm currently using the default_transport to route mail to 10025 for
> amavisd. Would I then just use the local transport for local mail then
> define it in the transport file?

No, because presumably the Bcc mail is supposed to be delivered
somewhere else via SMTP.  Instead, you would use a separate logical
domain for Bcc recipients, and route that domain (via a suitable
transport table entry) to a separate transport (perhaps bypass amavis
entirely, unless you need amavis to do something special with Bcc mail).

> Or perhaps local_recipient_maps? mydestination is not currently
> defined for this instance.

I thought I said transport...

-- 
Viktor.


Re: Configuring always_bcc

2021-04-21 Thread Alex
> > I should have made that more clear. The problem is that I'm trying to
> > create an address to which amavisd should forward all mail unfiltered,
> > but it only works if either all addresses are included in the policy
> > or the unfiltered address is the only address.
>
> This is why you have a multi-instance configuration.  You can use the
> transport table to selectively route specific recipients to specific
> filter transports, ... by avoiding content_filter and using normal
> Postfix transport-based routing.  This requires separate pre and
> post filter queues, which is what multiple instances give you.

I'm currently using the default_transport to route mail to 10025 for
amavisd. Would I then just use the local transport for local mail then
define it in the transport file? I believe this will impact other
locally delivered mail via procmail, which is why I'm asking before
experimenting. Or perhaps local_recipient_maps? mydestination is not
currently defined for this instance.


Re: Configuring always_bcc

2021-04-21 Thread Viktor Dukhovni
On Wed, Apr 21, 2021 at 03:29:07PM -0400, Alex wrote:

> I should have made that more clear. The problem is that I'm trying to
> create an address to which amavisd should forward all mail unfiltered,
> but it only works if either all addresses are included in the policy
> or the unfiltered address is the only address.

This is why you have a multi-instance configuration.  You can use the
transport table to selectively route specific recipients to specific
filter transports, ... by avoiding content_filter and using normal
Postfix transport-based routing.  This requires separate pre and
post filter queues, which is what multiple instances give you.

-- 
Viktor.


Re: Configuring always_bcc

2021-04-21 Thread Alex
Hi,

> >> > > Apr 21 10:58:24 xavier postfix-out/local[2682940]: 19D63305F4A09:
> >> > > to=, relay=local, delay=0.01, delays=0.01/0/0/0,
> >> > > dsn=2.0.0, status=sent (delivered to command: /usr/bin/procmail)
>
> it was delivered - what's the problem?
>
> >> > If you are running amavis as a content filter, you need the initial
> >> > postfix instance (which feeds into amavis) to have
> >> >
> >> > receive_override_options = no_address_mappings
> >> >
> >> > and then permit mappings (which include always_bcc) to occur in the 2nd
> >> > instance (for the mail that is returned by amavis), for example this
> >> > might be in master.cf by:
> >> >
> >> > 127.0.0.1:10025 inet n   -   n   -   -   smtpd
> >> ># note: absence of no_address_mappings means that address mapping
> >> > *will* occur here, including always_bcc
> >> >-o receive_override_options=no_unknown_recipient_checks,no_milters
> >> >...
> >>
> >> Okay, got it, thanks. This is now what I currently have:
> >>
> >> 127.0.0.1:10025 inet n-   n   -   16smtpd
> >> -o content_filter=
> >> -o smtpd_delay_reject=no
> >> -o smtpd_client_restrictions=permit_mynetworks,reject
> >> -o smtpd_helo_restrictions=
> >> -o smtpd_sender_restrictions=
> >> -o smtpd_recipient_restrictions=permit_mynetworks,reject
> >> -o smtpd_data_restrictions=reject_unauth_pipelining
> >> -o smtpd_end_of_data_restrictions=
> >> -o smtpd_restriction_classes=
> >> -o mynetworks=127.0.0.0/8,209.111.90.0/24,209.222.85.153/29
> >> -o smtpd_error_sleep_time=0
> >> -o smtpd_soft_error_limit=1001
> >> -o smtpd_hard_error_limit=1000
> >> -o smtpd_client_connection_count_limit=0
> >> -o smtpd_client_connection_rate_limit=0
> >> -o 
> >> receive_override_options=no_header_body_checks,no_unknown_recipient_checks,no_milters,no_address_mappings
> >> -o local_header_rewrite_clients=
>
> I recomment doing no_address_mappings on port 10025 when receiving mail from
> amavis, and not globally in the main.cf.
>
> On 21.04.21 12:49, Alex wrote:
> >This actually doesn't appear to have made any difference. What could I
> >be doing wrong?
>
> what difference? What are you trying to do and what does it do you don't
> expect/want ?

I should have made that more clear. The problem is that I'm trying to
create an address to which amavisd should forward all mail unfiltered,
but it only works if either all addresses are included in the policy
or the unfiltered address is the only address. For example:

@spam_lovers_maps = ( ['a...@example.com'] );
@bypass_spam_checks_maps = ( ['a...@example.com'] );

Also, we have a set of scripts that parse the log output and it's
being impacted by this bcc-user address. This also means that any mail
quarantined by amavisd for the recipient is also quarantined for the
bcc-user.

Thanks,
Alex


Re: Configuring always_bcc

2021-04-21 Thread Matus UHLAR - fantomas

> > How do I configure always_bcc to bypass amavisd altogether so it isn't
> > processed at all?
> >
> > # postconf -c /etc/postfix-116 always_bcc
> > always_bcc = bcc-user
> >
> > I'm unsure what postconf details I can provide, so I'll instead just
> > provide the log entries.
> >
> > Apr 21 10:58:24 xavier postfix-out/local[2682940]: 19D63305F4A09:
> > to=, relay=local, delay=0.01, delays=0.01/0/0/0,
> > dsn=2.0.0, status=sent (delivered to command: /usr/bin/procmail)


it was delivered - what's the problem?


> If you are running amavis as a content filter, you need the initial
> postfix instance (which feeds into amavis) to have
>
> receive_override_options = no_address_mappings
>
> and then permit mappings (which include always_bcc) to occur in the 2nd
> instance (for the mail that is returned by amavis), for example this
> might be in master.cf by:
>
> 127.0.0.1:10025 inet n   -   n   -   -   smtpd
># note: absence of no_address_mappings means that address mapping
> *will* occur here, including always_bcc
>-o receive_override_options=no_unknown_recipient_checks,no_milters
>...

Okay, got it, thanks. This is now what I currently have:

127.0.0.1:10025 inet n-   n   -   16smtpd
-o content_filter=
-o smtpd_delay_reject=no
-o smtpd_client_restrictions=permit_mynetworks,reject
-o smtpd_helo_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o smtpd_data_restrictions=reject_unauth_pipelining
-o smtpd_end_of_data_restrictions=
-o smtpd_restriction_classes=
-o mynetworks=127.0.0.0/8,209.111.90.0/24,209.222.85.153/29
-o smtpd_error_sleep_time=0
-o smtpd_soft_error_limit=1001
-o smtpd_hard_error_limit=1000
-o smtpd_client_connection_count_limit=0
-o smtpd_client_connection_rate_limit=0
-o 
receive_override_options=no_header_body_checks,no_unknown_recipient_checks,no_milters,no_address_mappings
-o local_header_rewrite_clients=


I recomment doing no_address_mappings on port 10025 when receiving mail from
amavis, and not globally in the main.cf.

On 21.04.21 12:49, Alex wrote:

This actually doesn't appear to have made any difference. What could I
be doing wrong?


what difference? What are you trying to do and what does it do you don't
expect/want ?

--
Matus UHLAR - fantomas, uh...@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
10 GOTO 10 : REM (C) Bill Gates 1998, All Rights Reserved!


Re: Configuring always_bcc

2021-04-21 Thread Viktor Dukhovni
On Wed, Apr 21, 2021 at 11:17:19AM -0400, Alex wrote:

> I have postfix configured in a multi-instance setup in conjunction
> with amavisd. I'm using always_bcc to create a copy of each email sent
> or received.

This does not create a "copy", it adds a recipient to the message.

> The problem is that, while postfix appears to deliver the bcc-user
> email separately from the other recipients,

This is not the case, the bcc user is treated just like any other
recipient.  If all the other users are sent in one go to a content
filter, the same will be true for the Bcc recipients.

> amavis somehow delivers to all the recipients, including the bcc-user,
> as one email.

Why is that a problem?  Ultimately the message is delivered to all
the recipients, including the bcc recipiets, and at some point the
envelope may split with separate per mailbox deliveries.

> How do I configure always_bcc to bypass amavisd altogether so it isn't
> processed at all?

In a single instance deployment, you can't.  Content filters apply to
all recipients.  In a multi-instance deployment, you avoid using
"content_filter" and use the transport table to select the appropriate
delivery mechanism for each recipient domain:

input instance --->  filter1 > output instance
  .
   --->  filterN >

One of the "filter" channels can be a direct connection to the output
instance, bypassing filtering.

-- 
Viktor.


Re: Configuring always_bcc

2021-04-21 Thread Alex
Hi,

> > > How do I configure always_bcc to bypass amavisd altogether so it isn't
> > > processed at all?
> > >
> > > # postconf -c /etc/postfix-116 always_bcc
> > > always_bcc = bcc-user
> > >
> > > I'm unsure what postconf details I can provide, so I'll instead just
> > > provide the log entries.
> > >
> > > Apr 21 10:58:24 xavier postfix-out/local[2682940]: 19D63305F4A09:
> > > to=, relay=local, delay=0.01, delays=0.01/0/0/0,
> > > dsn=2.0.0, status=sent (delivered to command: /usr/bin/procmail)
> > >
> > > ...
> >
> > If you are running amavis as a content filter, you need the initial
> > postfix instance (which feeds into amavis) to have
> >
> > receive_override_options = no_address_mappings
> >
> > and then permit mappings (which include always_bcc) to occur in the 2nd
> > instance (for the mail that is returned by amavis), for example this
> > might be in master.cf by:
> >
> > 127.0.0.1:10025 inet n   -   n   -   -   smtpd
> ># note: absence of no_address_mappings means that address mapping
> > *will* occur here, including always_bcc
> >-o receive_override_options=no_unknown_recipient_checks,no_milters
> >...
>
> Okay, got it, thanks. This is now what I currently have:
>
> 127.0.0.1:10025 inet n-   n   -   16smtpd
> -o content_filter=
> -o smtpd_delay_reject=no
> -o smtpd_client_restrictions=permit_mynetworks,reject
> -o smtpd_helo_restrictions=
> -o smtpd_sender_restrictions=
> -o smtpd_recipient_restrictions=permit_mynetworks,reject
> -o smtpd_data_restrictions=reject_unauth_pipelining
> -o smtpd_end_of_data_restrictions=
> -o smtpd_restriction_classes=
> -o mynetworks=127.0.0.0/8,209.111.90.0/24,209.222.85.153/29
> -o smtpd_error_sleep_time=0
> -o smtpd_soft_error_limit=1001
> -o smtpd_hard_error_limit=1000
> -o smtpd_client_connection_count_limit=0
> -o smtpd_client_connection_rate_limit=0
> -o 
> receive_override_options=no_header_body_checks,no_unknown_recipient_checks,no_milters,no_address_mappings
> -o local_header_rewrite_clients=

This actually doesn't appear to have made any difference. What could I
be doing wrong?

Thanks,
Alex


Re: Configuring always_bcc

2021-04-21 Thread Alex
Hi,

On Wed, Apr 21, 2021 at 11:31 AM Dominic Raferd  wrote:
>
> On 21/04/2021 16:17, Alex wrote:
> > I have postfix configured in a multi-instance setup in conjunction
> > with amavisd. I'm using always_bcc to create a copy of each email sent
> > or received.
> >
> > The problem is that, while postfix appears to deliver the bcc-user
> > email separately from the other recipients, amavis somehow delivers to
> > all the recipients, including the bcc-user, as one email.
> >
> > How do I configure always_bcc to bypass amavisd altogether so it isn't
> > processed at all?
> >
> > # postconf -c /etc/postfix-116 always_bcc
> > always_bcc = bcc-user
> >
> > I'm unsure what postconf details I can provide, so I'll instead just
> > provide the log entries.
> >
> > Apr 21 10:58:24 xavier postfix-out/local[2682940]: 19D63305F4A09:
> > to=, relay=local, delay=0.01, delays=0.01/0/0/0,
> > dsn=2.0.0, status=sent (delivered to command: /usr/bin/procmail)
> >
> > ...
>
> If you are running amavis as a content filter, you need the initial
> postfix instance (which feeds into amavis) to have
>
> receive_override_options = no_address_mappings
>
> and then permit mappings (which include always_bcc) to occur in the 2nd
> instance (for the mail that is returned by amavis), for example this
> might be in master.cf by:
>
> 127.0.0.1:10025 inet n   -   n   -   -   smtpd
># note: absence of no_address_mappings means that address mapping
> *will* occur here, including always_bcc
>-o receive_override_options=no_unknown_recipient_checks,no_milters
>...

Okay, got it, thanks. This is now what I currently have:

127.0.0.1:10025 inet n-   n   -   16smtpd
-o content_filter=
-o smtpd_delay_reject=no
-o smtpd_client_restrictions=permit_mynetworks,reject
-o smtpd_helo_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o smtpd_data_restrictions=reject_unauth_pipelining
-o smtpd_end_of_data_restrictions=
-o smtpd_restriction_classes=
-o mynetworks=127.0.0.0/8,209.111.90.0/24,209.222.85.153/29
-o smtpd_error_sleep_time=0
-o smtpd_soft_error_limit=1001
-o smtpd_hard_error_limit=1000
-o smtpd_client_connection_count_limit=0
-o smtpd_client_connection_rate_limit=0
-o 
receive_override_options=no_header_body_checks,no_unknown_recipient_checks,no_milters,no_address_mappings
-o local_header_rewrite_clients=

Thanks so much,
Alex


Re: Configuring always_bcc

2021-04-21 Thread Dominic Raferd

On 21/04/2021 16:17, Alex wrote:

I have postfix configured in a multi-instance setup in conjunction
with amavisd. I'm using always_bcc to create a copy of each email sent
or received.

The problem is that, while postfix appears to deliver the bcc-user
email separately from the other recipients, amavis somehow delivers to
all the recipients, including the bcc-user, as one email.

How do I configure always_bcc to bypass amavisd altogether so it isn't
processed at all?

# postconf -c /etc/postfix-116 always_bcc
always_bcc = bcc-user

I'm unsure what postconf details I can provide, so I'll instead just
provide the log entries.

Apr 21 10:58:24 xavier postfix-out/local[2682940]: 19D63305F4A09:
to=, relay=local, delay=0.01, delays=0.01/0/0/0,
dsn=2.0.0, status=sent (delivered to command: /usr/bin/procmail)

...


If you are running amavis as a content filter, you need the initial 
postfix instance (which feeds into amavis) to have


receive_override_options = no_address_mappings

and then permit mappings (which include always_bcc) to occur in the 2nd 
instance (for the mail that is returned by amavis), for example this 
might be in master.cf by:


127.0.0.1:10025 inet n   -   n   -   -   smtpd
  # note: absence of no_address_mappings means that address mapping 
*will* occur here, including always_bcc

  -o receive_override_options=no_unknown_recipient_checks,no_milters
  ...



Configuring always_bcc

2021-04-21 Thread Alex
Hi,

I have postfix configured in a multi-instance setup in conjunction
with amavisd. I'm using always_bcc to create a copy of each email sent
or received.

The problem is that, while postfix appears to deliver the bcc-user
email separately from the other recipients, amavis somehow delivers to
all the recipients, including the bcc-user, as one email.

How do I configure always_bcc to bypass amavisd altogether so it isn't
processed at all?

# postconf -c /etc/postfix-116 always_bcc
always_bcc = bcc-user

I'm unsure what postconf details I can provide, so I'll instead just
provide the log entries.

Apr 21 10:58:24 xavier postfix-out/local[2682940]: 19D63305F4A09:
to=, relay=local, delay=0.01, delays=0.01/0/0/0,
dsn=2.0.0, status=sent (delivered to command: /usr/bin/procmail)

Apr 21 10:58:24 xavier postfix-116/smtp[2670710]: 2147710036E1C:
to=,relay=127.0.0.1[127.0.0.1]:10024, delay=3.3,
delays=1.2/0/0/2.1, dsn=2.0.0, status=sent (250 2.0.0 from
MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as 19D63305F4A09)

Apr 21 10:58:24 xavier postfix-116/smtp[2670710]: 2147710036E1C:
to=<54...@example.com>, relay=127.0.0.1[127.0.0.1]:10024, delay=3.3,
delays=1.2/0/0/2.1, dsn=2.0.0, status=sent (250 2.0.0 from
MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as 19D63305F4A09)

Apr 21 10:58:24 xavier postfix-out/smtp[2680850]: 19D63305F4A09:
to=<54...@example.com>,relay=209.216.94.60[209.216.94.60]:25,
delay=0.08, delays=0.01/0/0.01/0.06, dsn=2.0.0, status=sent (250 2.0.0
Ok: queued as 1F9401B0E0FEE)

Apr 21 10:58:24 xavier amavis[2683075]: (2683075-03) g5Zwhwdfsn5D FWD
from  ->
,<54...@example.com>, BODY=7BIT 250 2.0.0 from
MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as 19D63305F4A09

Thanks,
Alex


Re: REDIRECT overrides always_bcc

2021-04-20 Thread Matus UHLAR - fantomas

On 2021-04-16 12:03, Dominic Raferd wrote:
> I have started using a REDIRECT action in a header_checks table
> which works but seems to prevent always_bcc from operating -
> the email is not bcc'd.



On Fri, 16 Apr 2021, 20:07 Rob McGee,  wrote:

It's ugly, but a possible workaround: REDIRECT to an address which
runs a script (transport_maps entry to a pipe(8) or to a local(8)
address with a ~/.forward), and the script delivers a copy to your
BCC address by some means.


On 19.04.21 21:47, Dominic Raferd wrote:

Thanks for this suggestion, I might well implement it


which reminds me, I have simply added the address in always_bcc to an alias
where such mail is redirected.

--
Matus UHLAR - fantomas, uh...@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
Linux is like a teepee: no Windows, no Gates and an apache inside...


Re: REDIRECT overrides always_bcc

2021-04-19 Thread Dominic Raferd
On Fri, 16 Apr 2021, 20:07 Rob McGee,  wrote:

> On 2021-04-16 12:03, Dominic Raferd wrote:
> > I have started using a REDIRECT action in a header_checks table
> > which works but seems to prevent always_bcc from operating -
> > the email is not bcc'd.
>
> It's ugly, but a possible workaround: REDIRECT to an address which
> runs a script (transport_maps entry to a pipe(8) or to a local(8)
> address with a ~/.forward), and the script delivers a copy to your
> BCC address by some means.
>

Thanks for this suggestion, I might well implement it

>


Re: REDIRECT overrides always_bcc

2021-04-16 Thread Rob McGee

On 2021-04-16 12:03, Dominic Raferd wrote:

I have started using a REDIRECT action in a header_checks table
which works but seems to prevent always_bcc from operating -
the email is not bcc'd.


It's ugly, but a possible workaround: REDIRECT to an address which
runs a script (transport_maps entry to a pipe(8) or to a local(8)
address with a ~/.forward), and the script delivers a copy to your
BCC address by some means.

It's ugly, but the idea of redirecting based on a header is also
ugly. :)
--
  http://rob0.nodns4.us/


Re: REDIRECT overrides always_bcc

2021-04-16 Thread Dominic Raferd

On 16/04/2021 18:39, Wietse Venema wrote:

Dominic Raferd:

I have started using a REDIRECT action in a header_checks table which
works but seems to prevent always_bcc from operating - the email is not
bcc'd.

REDIRECT is a blunt tool that ignores all recipients. If there are
multiple redirect actions, then the last action will take effect.
Theoretically it would be possible to parse the REDIRECT argument
as an address list, but demand for this has been rare. Multi address
support would have to be implemented for every BCC feature, otherwise
we'd drive people insane with inconsistencies.

Well that's a shame but thanks for explaining it Wietse


Re: REDIRECT overrides always_bcc

2021-04-16 Thread Wietse Venema
Dominic Raferd:
> I have started using a REDIRECT action in a header_checks table which 
> works but seems to prevent always_bcc from operating - the email is not 
> bcc'd.

REDIRECT is a blunt tool that ignores all recipients. If there are
multiple redirect actions, then the last action will take effect.
Theoretically it would be possible to parse the REDIRECT argument
as an address list, but demand for this has been rare. Multi address
support would have to be implemented for every BCC feature, otherwise
we'd drive people insane with inconsistencies.

Wietse

> I tried adding a subsequent BCC action triggered by the same header text 
> but it has no effect. I realise that this is consistent with 
> documentation but is there a way to do the redirection and still do bcc 
> as well? So far as I can see redirection is only supported to one 
> address, not two?
> 
> 


REDIRECT overrides always_bcc

2021-04-16 Thread Dominic Raferd
I have started using a REDIRECT action in a header_checks table which 
works but seems to prevent always_bcc from operating - the email is not 
bcc'd.


I tried adding a subsequent BCC action triggered by the same header text 
but it has no effect. I realise that this is consistent with 
documentation but is there a way to do the redirection and still do bcc 
as well? So far as I can see redirection is only supported to one 
address, not two?




Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-05 Thread Viktor Dukhovni
On Fri, Mar 05, 2021 at 04:25:38AM -0500, Viktor Dukhovni wrote:

> There are only two common ways a message without duplicated recipients
> gets delivered to the same mailbox twice:
> 
>1. Address rewriting (including BCC maps) duplicates a recipient,
>   and "enable_original_recipient" is not set to "no".
> 
>2. A message with multiple recipients is delivered via multiple
>   transport:nexthop combinations, the separate messages then
>   get augmented with (or rewritten to) a common recipient.
> 
> A third less common way is via local(8) aliases, because local
> delivery splits the envelope to one recipient at a time before
> alias(5) expansion.

I glossed over one detail in (2), the envelope also splits when a
message has more recipients than the transport's destination recipient
limit.  I generally give content filter transports a much higher than
default recipient limit, e.g. 1000, rather than the default of 50.

The OP's use-case had just a handful of recipients, so this is not
an immediate a concern in this thread.

-- 
Viktor.


Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-05 Thread Wietse Venema
Tom Hendrikx:
> Isn't this as simple as:
> 
> 1. new email comes in, is delivered to content filter, with bcc to 
> always_bcc recipient.

That is what is supposed to happen. 

But see my description of what happens with a broken configuration.

> 2. content filter re-injects email into the queue for final delivery, 
> postfix performs final delivery, with bcc to the always_bcc recipient?

That is not supposed to happen. 

The mail FROM the filter is supposed to already have an always_bcc
recipient, and therefore Postfix is not supposed to add another one.

But see my desciption of how deduplication can be disabled.

Wietse


Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-05 Thread Steve Dondley
On Fri, Mar 5, 2021 at 4:26 AM Viktor Dukhovni
 wrote:
>
> On Fri, Mar 05, 2021 at 03:41:06AM -0500, Steve Dondley wrote:
>
> > Here are postfix config file: https://pastebin.com/bZxjHF5y
>
> I don't usually go chasing pastebin URLs...
>
> > Hopefully something jumps out at you.
>
> There are only two common ways a message without duplicated recipients
> gets delivered to the same mailbox twice:
>
>1. Address rewriting (including BCC maps) duplicates a recipient,
>   and "enable_original_recipient" is not set to "no".
>
>2. A message with multiple recipients is delivered via multiple
>   transport:nexthop combinations, the separate messages then
>   get augmented with (or rewritten to) a common recipient.
>
> A third less common way is via local(8) aliases, because local
> delivery splits the envelope to one recipient at a time before
> alias(5) expansion.
>
> I don't recommend use of local aliases for anything other than
> ":include:" or "|command" support.  Do all ordinary address -> address
> rewriting via virtual aliases instead.
>
> Either or both may be happening in your case, and your job is to
> find out which.
>
> The first is easy, make sure "enable_original_recipient = no".
>
> The second can happen if your "content_filter" does not specify an
> explicit fixed nexthop.  Normally, that would be something like:
>
> scan:[127.0.0.1]:10024
>
> but if for some reason your content filter is just a transport name,
> then implicitly the "nexthop" is the recipient domain, and recipients in
> different domains are delivered separately (creating multiple copies of
> the message into the filter).
>
> So long as the envelope is not split, and within a single envelope
> address duplication is suppressed, delivery will not be duplicated by
> Postfix if not already duplicated before it got to Postfix.
>
> If you internalise the above logic, you won't need to guess, you
> can just find where the envelope splits, prior to BCC rewrites.
>
> It is also best to avoid adding the BCC address more than once, so
> ideally enable address rewriting either only before or only after the
> content filter.  Look for "receive_override_options" in FILTER_README.
>
> --
> Viktor.

What I'm going to to do is start with a minimal postfix install and
rebuild from scratch and do some testing. Best way to learn this, I
think. Thanks for your help.


Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-05 Thread Steve Dondley
> 1. new email comes in, is delivered to content filter, with bcc to
> always_bcc recipient.
> 2. content filter re-injects email into the queue for final delivery,
> postfix performs final delivery, with bcc to the always_bcc recipient?
>
> Since these are 2 separate deliveries (with different routes) as far as
> postfix is concerned,there will be 2 messages to the always_bcc
> receipient, and no deduplication.

OK, I appreciate the additional help. I'm going to take a very long
look at this this weekend. I'll get it figured out.



--
Prometheus Labor Communications, Inc.
http://prometheuslabor.com
413-572-1300

UnionConnect Phone App for Labor Unions
http://unionconnect.com


Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-05 Thread Viktor Dukhovni
On Fri, Mar 05, 2021 at 03:41:06AM -0500, Steve Dondley wrote:

> Here are postfix config file: https://pastebin.com/bZxjHF5y

I don't usually go chasing pastebin URLs...

> Hopefully something jumps out at you.

There are only two common ways a message without duplicated recipients
gets delivered to the same mailbox twice:

   1. Address rewriting (including BCC maps) duplicates a recipient,
  and "enable_original_recipient" is not set to "no".

   2. A message with multiple recipients is delivered via multiple
  transport:nexthop combinations, the separate messages then
  get augmented with (or rewritten to) a common recipient.

A third less common way is via local(8) aliases, because local
delivery splits the envelope to one recipient at a time before
alias(5) expansion.

I don't recommend use of local aliases for anything other than
":include:" or "|command" support.  Do all ordinary address -> address
rewriting via virtual aliases instead.

Either or both may be happening in your case, and your job is to
find out which.

The first is easy, make sure "enable_original_recipient = no".

The second can happen if your "content_filter" does not specify an
explicit fixed nexthop.  Normally, that would be something like:

scan:[127.0.0.1]:10024

but if for some reason your content filter is just a transport name,
then implicitly the "nexthop" is the recipient domain, and recipients in
different domains are delivered separately (creating multiple copies of
the message into the filter).

So long as the envelope is not split, and within a single envelope
address duplication is suppressed, delivery will not be duplicated by
Postfix if not already duplicated before it got to Postfix.

If you internalise the above logic, you won't need to guess, you
can just find where the envelope splits, prior to BCC rewrites.

It is also best to avoid adding the BCC address more than once, so
ideally enable address rewriting either only before or only after the
content filter.  Look for "receive_override_options" in FILTER_README.

-- 
Viktor.


Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-05 Thread Tom Hendrikx




On 05-03-2021 09:41, Steve Dondley wrote:

You may also have disabled recipient duplication. We will
never knwo unles yo reveal yur configration as described
in http://www.postfix.org/DEBUG_README.html#mail.


I've been looking at this a lng time tonight. Despite my best
efforts, I did not find a reason for the duplicate email.

I even created my own content filter to rule out some kind of
spamassassin/spamc/spamd miconfiguration. I'm still receiving emails
twice with this customs content filter turned on (only once with the
content filter turned ooff).

I turned on verbose for cleanup and trivial-rewrite but there was so
much output and much of it repetitive that it didn't help me determine
what's going on.

Here are postfix config file: https://pastebin.com/bZxjHF5y

Hopefully something jumps out at you.



Isn't this as simple as:

1. new email comes in, is delivered to content filter, with bcc to 
always_bcc recipient.
2. content filter re-injects email into the queue for final delivery, 
postfix performs final delivery, with bcc to the always_bcc recipient?


Since these are 2 separate deliveries (with different routes) as far as 
postfix is concerned,there will be 2 messages to the always_bcc 
receipient, and no deduplication.


Kind regards,
Tom


Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-05 Thread Steve Dondley
> You may also have disabled recipient duplication. We will
> never knwo unles yo reveal yur configration as described
> in http://www.postfix.org/DEBUG_README.html#mail.

I've been looking at this a lng time tonight. Despite my best
efforts, I did not find a reason for the duplicate email.

I even created my own content filter to rule out some kind of
spamassassin/spamc/spamd miconfiguration. I'm still receiving emails
twice with this customs content filter turned on (only once with the
content filter turned ooff).

I turned on verbose for cleanup and trivial-rewrite but there was so
much output and much of it repetitive that it didn't help me determine
what's going on.

Here are postfix config file: https://pastebin.com/bZxjHF5y

Hopefully something jumps out at you.


Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-04 Thread Wietse Venema
Steve Dondley:
> > If 'always_bcc' produces three copies (with spamassassin turned on)
> > for one email message with three recipients, then Postfix is
> 
> It's actually generating 3 emails even if sending to only one recipient.

Consider that Postfix deduplicates recipients. If you add a fixed
recipient with always_bcc as the message traverses through Postfix,
then it should deduplicate to one always_bcc recipient.

However, you can easily brreak alwaysbcc dedupliucation by setting
spamassassin_destination_recipient_limit=1 or
default_destination_recipient_limit=1 which forces Postfix to split
deliveries to the content filter as folllows:

1) Before filter, one message, Postfix has added one alwaysbcc recipient
- original recipient
- alwaysbcc recipient

Postfix delivers to the filter: messages 2) and 3) each with one recipient

2) One copy if message 1) with only the original recipient
- original recipient

3) One copy if message 1) with only the alwaysbcc recipient
- alwaysbcc recipient

Filter delivers to Postfix: messages 2) and 3) each with one recipient.

After Postfix receives the messages it produces messages 4) and 5)

4) One copy of message 2) after Postfix has added one alwaysbcc recipient
- original recipient
- alwaysbcc recipient

5) One copy of message 3) Postfix does not add another alwaysbcc recipient
(because Postfix deduplicates recipients)
- alwaysbcc recipient

So now you have to email messages that will be sent to your alwaysbcc
recipient.

I am not going to give an example of how you end up with three
messages.  You have all the information in the maillog file
(status=sent logging) and in the message headers.

You may also have disabled recipient duplication. We will
never knwo unles yo reveal yur configration as described
in http://www.postfix.org/DEBUG_README.html#mail.

Wietse


Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-04 Thread Steve Dondley
> If 'always_bcc' produces three copies (with spamassassin turned on)
> for one email message with three recipients, then Postfix is

It's actually generating 3 emails even if sending to only one recipient.

> mis-configured, for example, to deliver three one-recipient messages
> to the content filter.

What I'm trying to figure out is if turning spamassassin on for the
submission service is considered to be a  misconfiguration.

Is there any reason to run email generated by users on the server
through spamassassin?

> If a pre-packaged solution works for you then may well be a better
> option than building something by pasting random stuff from the web.

Well, I set it up per an official debian wiki. I wouldn't exactly
classify that as random.


Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-04 Thread Wietse Venema
Steve Dondley:
> OK, I don't feel quite so foolish. The guide here is what I apparently
> followed when I initially set up spamassassin:
> 
> https://wiki.debian.org/DebianSpamAssassin
> 
> So I now know how to fix the duplicates by removing the "-o
> content_filter=spamassassin"
> 
> However, if I want to leave that in (which I apparently do), how do I
> properly stop duplicates from happening?

If 'always_bcc' produces three copies (with spamassassin turned on)
for one email message with three recipients, then Postfix is
mis-configured, for example, to deliver three one-recipient messages
to the content filter.

If a pre-packaged solution works for you then may well be a better
option than building something by pasting random stuff from the web.

Wietse



Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-04 Thread Steve Dondley
> do a lot of your own homework (because everyone here is busy). If this
> doesn't appeal, consider using a recipe for a postfix-based mail server
> such as https://mailinabox.email/ or https://www.iredmail.org/. You lose
> the flexibility of a bespoke setup but you get back some of your life -
> I speak as someone who lost it ;-)

I just took a closer look at iredemail. Now I see that it's basically
doing what I'm trying to do for my existing clients. Now I'm
intrigued.  Thanks for reminding me about it.

Any preference for mailinabox over iredmail. ired looks like it has
calendar functionality.


Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-04 Thread Steve Dondley
OK, I don't feel quite so foolish. The guide here is what I apparently
followed when I initially set up spamassassin:

https://wiki.debian.org/DebianSpamAssassin

So I now know how to fix the duplicates by removing the "-o
content_filter=spamassassin"

However, if I want to leave that in (which I apparently do), how do I
properly stop duplicates from happening?

On Thu, Mar 4, 2021 at 2:17 PM Steve Dondley  wrote:
>
> I think I found the root cause of the problem (other than me being a
> clueless idiot). I had this in my master.cf:
>
> smtp inet  n - y - -smtpd
>  -o content_filter=spamassassin
>
> submission inet  n - y - -smtpe
> -o content_filter=spamassassin
>   -o syslog_name=postfix/submission
>   -o smtpd_tls_security_level=may
>   -o smtpd_sasl_auth_enable=yes
>
> Removing the second SA content filter in the "submission" stanza did
> the trick. I was wondering why outgoing mail was getting fed through
> SA. It's not supposed to be, is it?
>
> On Thu, Mar 4, 2021 at 2:14 PM Wietse Venema  wrote:
> >
> > Does the Postfix configuration send three copies to the filter, one for 
> > each recipient?
> > Don't do that, it is wasteful.
> >
> > Wietse
>
>
>
> --
> Prometheus Labor Communications, Inc.
> http://prometheuslabor.com
> 413-572-1300
>
> UnionConnect Phone App for Labor Unions
> http://unionconnect.com



-- 
Prometheus Labor Communications, Inc.
http://prometheuslabor.com
413-572-1300

UnionConnect Phone App for Labor Unions
http://unionconnect.com


Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-04 Thread Steve Dondley
I think I found the root cause of the problem (other than me being a
clueless idiot). I had this in my master.cf:

smtp inet  n - y - -smtpd
 -o content_filter=spamassassin

submission inet  n - y - -smtpe
-o content_filter=spamassassin
  -o syslog_name=postfix/submission
  -o smtpd_tls_security_level=may
  -o smtpd_sasl_auth_enable=yes

Removing the second SA content filter in the "submission" stanza did
the trick. I was wondering why outgoing mail was getting fed through
SA. It's not supposed to be, is it?

On Thu, Mar 4, 2021 at 2:14 PM Wietse Venema  wrote:
>
> Does the Postfix configuration send three copies to the filter, one for each 
> recipient?
> Don't do that, it is wasteful.
>
> Wietse



-- 
Prometheus Labor Communications, Inc.
http://prometheuslabor.com
413-572-1300

UnionConnect Phone App for Labor Unions
http://unionconnect.com


Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-04 Thread Wietse Venema
Does the Postfix configuration send three copies to the filter, one for each 
recipient?
Don't do that, it is wasteful.

Wietse


Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-04 Thread Viktor Dukhovni
On Thu, Mar 04, 2021 at 01:24:59PM -0500, Steve Dondley wrote:

> After staring at these logs some more and piecing together the advice
> here, here's my understanding of what's happening:
> 
> * Mail comes in via smtpd as user sends mail. It's going to 3
> recipients. I'm not sure who those might be. Maybe the catchall
> account and the two users the email is going to?

If the user addresses three recipients in a single message, that message
will get one queue-id when initially accepted by Postfix.  So, one
message, three envelope recipients.

When does the envelope split?  That is, when do you see more than one
queue-id with the original message-id?

When do you add Bcc recipients?

> * Mail goes into the qmgr

Messages don't go into "qmgr", it just schedules their delivery,
messages come via smtpd+cleanup or pickup+cleanup.  You should see log
messages from these showing message "arrival", especially "cleanup",
which reports both the queue-id and the message-id.

What you get out of the qmgr log entries is the number of envelope
recipients of the queue-id in question. The rest is not important
in this context.

What are then more interesting are log messages from delivery agents,
particularly smtp(8), which reports both the queue-id of the current
message, and the response from the remote server, which often has
the upstream queue-id.

If not all the recipients of a message delivered via smtp(8) show the
same nexthop relay and nexthop reply text, then the envelope was
split, and any downstream processing is now happening on multiple
copies of the message.

> * Mail gets filtered by spamassassin

How many times?

> * filtered mail comes back to qmgr so qmgr can start delivering them

Again, not "qmgr" but smtpd+cleanup.

> * a copy of the email goes out to catchall

If a BCC was added by cleanup(8), then the message will have an extra
envelope recipient, that's the thing to look for.  Are more recipients
present than accounted for from the source.

> * a second copy of the email goes out to catchall, twice. I don't know why.

You're not reading the logs carefully.

-- 
Viktor.


Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-04 Thread Steve Dondley
After staring at these logs some more and piecing together the advice
here, here's my understanding of what's happening:

* Mail comes in via smtpd as user sends mail. It's going to 3
recipients. I'm not sure who those might be. Maybe the catchall
account and the two users the email is going to?

* Mail goes into the qmgr

* Mail gets filtered by spamassassin

* filtered mail comes back to qmgr so qmgr can start delivering them

* a copy of the email goes out to catchall

* qmgr removes this copy

* a second copy of the email goes out to catchall, twice. I don't know why.

* this point, catchall has received the email 3 times.

* qmgr removes that email from the queue

* Finally, an email get sent out to each of the two original
recipients on the email


Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-04 Thread Steve Dondley
Here's an anonymized pastebin example of my actual log entries of an
outgoing email that generated 3 copies: https://pastebin.com/cw2XB5jp
to the "catchall" mailbox.

> It is worthwhile to know if the duplicates are caused by adding
> multiple 'always_bcc' addresses to the same queue file.
>
> Look for logging with "message-id=".
>
> Mar  4 01:05:05 mail postfix/cleanup[30124]: foo:
> message-id= Look for "qmgr" logging with "foo", and note the "nrcpt="
> which indicates the number of recipients. Compare the numbers before
> the content filter and after the content filter.

It initially is set to 3. Then later it changes to 2.


Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-04 Thread Steve Dondley
> - mail comes to postfix (smtp or local injection)
>   = address mappings (always_bcc) happen
> - postfix sends mail to spamassassin
> - spamassassin scans mail and sends to postfix
>   = address mappings (always_bcc) happen
>
> one of those should be avoided by no_address_mappings but choose wisely...

So it sounds like I just want to add no_address_mappings to the
spamassassin filter then?


Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-04 Thread Matus UHLAR - fantomas

you only use should no_address_mappings if your mail loops back, not
generally - you usually want alias expantion, canonical mapping, and
automatic BCC (at least if you configure any of those).


On 04.03.21 08:10, Steve Dondley wrote:

Sorry, I don't follow you.


- mail comes to postfix (smtp or local injection)
 = address mappings (always_bcc) happen
- postfix sends mail to spamassassin
- spamassassin scans mail and sends to postfix
 = address mappings (always_bcc) happen

one of those should be avoided by no_address_mappings but choose wisely...


I'm on debian. As far as I can gather, all mail related activity is
logged in /var/log/mail.log. Is that log all I need to help determine
where the duplicate emails are coming from? If so I can study that and
probably figure this out.


--
Matus UHLAR - fantomas, uh...@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
Fucking windows! Bring Bill Gates! (Southpark the movie)


Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-04 Thread Wietse Venema
Steve Dondley:
> > The info can be found in the maillog file, and the Received: headers
> > of the messages as delivered. Welcome to the vortex.
> 
> After a close inspection of the headers, I can see that all the email
> received have headers injected by spamassassin and this revealing
> line:
> 
> "Received: by email.example.com (Postfix, from userid 115)"
> 
> User 115 is "debian-spamd". So I'm guessing I must have configured SA
> poorly. I probably know even less about SA than postfix. :)

The content filter sends messages back info Postfix similar to
http://www.postfix.org/FILTER_README.html#simple_filter

It is worthwhile to know if the duplicates are caused by adding
multiple 'always_bcc' addresses to the same queue file.

Look for logging with "message-id=".

Mar  4 01:05:05 mail postfix/cleanup[30124]: foo:
message-id="
which indicates the number of recipients. Compare the numbers before
the content filter and after the content filter.

Mar  4 01:05:05 mail postfix/qmgr[28026]: foo:
from=, size=1234, nrcpt=1 (queue active)

It will give an idea why you get three copies.

Wietse


Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-04 Thread Steve Dondley
> The info can be found in the maillog file, and the Received: headers
> of the messages as delivered. Welcome to the vortex.

After a close inspection of the headers, I can see that all the email
received have headers injected by spamassassin and this revealing
line:

"Received: by email.example.com (Postfix, from userid 115)"

User 115 is "debian-spamd". So I'm guessing I must have configured SA
poorly. I probably know even less about SA than postfix. :)

Thanks for your help!







-- 
Prometheus Labor Communications, Inc.
http://prometheuslabor.com
413-572-1300

UnionConnect Phone App for Labor Unions
http://unionconnect.com


Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-04 Thread Wietse Venema
Steve Dondley:
> > you only use should no_address_mappings if your mail loops back, not
> > generally - you usually want alias expantion, canonical mapping, and
> > automatic BCC (at least if you configure any of those).
> 
> Sorry, I don't follow you.
> 
> I'm on debian. As far as I can gather, all mail related activity is
> logged in /var/log/mail.log. Is that log all I need to help determine
> where the duplicate emails are coming from? If so I can study that and
> probably figure this out.

The info can be found in the maillog file, and the Received: headers
of the messages as delivered. Welcome to the vortex.

Wietse


Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-04 Thread Steve Dondley
> you only use should no_address_mappings if your mail loops back, not
> generally - you usually want alias expantion, canonical mapping, and
> automatic BCC (at least if you configure any of those).

Sorry, I don't follow you.

I'm on debian. As far as I can gather, all mail related activity is
logged in /var/log/mail.log. Is that log all I need to help determine
where the duplicate emails are coming from? If so I can study that and
probably figure this out.


Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-04 Thread Steve Dondley
On Thu, Mar 4, 2021 at 7:48 AM Dominic Raferd  wrote:
>
> On 04/03/2021 11:42, Steve Dondley wrote:
> >> On 03.03.21 18:23, Steve Dondley wrote:
> >>> I have enabled the always_bcc setting with:
> >>>
> >>> always_bcc = exam...@example.org
> >>>
> >>> It works, but I'm getting everything three times. How do I prevent 
> >>> duplicates?
> >> this can happen if you use content_filter that feeds mail back to postfix.
> > OK, yeah, I got spam assassin installed and have this line in
> > master.cf for smtp:
> >
> > -o content_filter=spamassassin
> Steve: if you are keen to become a real postfix and mail server nerd,
> you are in the right place, but my impression from your
> comments/questions is that you have a lot to learn and you will need to
> do a lot of your own homework (because everyone here is busy).

No doubt. Grinding my way through and asking questions to see what
happens. I have no expectations and make no demands.

You lose
> the flexibility of a bespoke setup but you get back some of your life -
> I speak as someone who lost it ;-)

I'm afraid it's too late. I'm too vested and have slipped into the
vortex. I don't care anything about getting a life back and
fortunately I have oodles of time.


Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-04 Thread Dominic Raferd

On 04/03/2021 11:42, Steve Dondley wrote:

On 03.03.21 18:23, Steve Dondley wrote:

I have enabled the always_bcc setting with:

always_bcc = exam...@example.org

It works, but I'm getting everything three times. How do I prevent duplicates?

this can happen if you use content_filter that feeds mail back to postfix.

OK, yeah, I got spam assassin installed and have this line in
master.cf for smtp:

-o content_filter=spamassassin
Steve: if you are keen to become a real postfix and mail server nerd, 
you are in the right place, but my impression from your 
comments/questions is that you have a lot to learn and you will need to 
do a lot of your own homework (because everyone here is busy). If this 
doesn't appeal, consider using a recipe for a postfix-based mail server 
such as https://mailinabox.email/ or https://www.iredmail.org/. You lose 
the flexibility of a bespoke setup but you get back some of your life - 
I speak as someone who lost it ;-)


Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-04 Thread Matus UHLAR - fantomas

>-o content_filter=spamassassin

the question is, how does spamassassin push mail back to postfix.


On 04.03.21 07:06, Steve Dondley wrote:

I have no earthly idea. Not sure how SA works, exactly.


It's not how SA works, it's how it's configured in master.cf.


And it makes me wonder if I'm breaking spam assassin by adding

-o receive_override_options=no_address_mappings

to my configuration. How would I figure that out?


don't add that - this is option for smtpd, not for spamassassin.

you only use should no_address_mappings if your mail loops back, not
generally - you usually want alias expantion, canonical mapping, and
automatic BCC (at least if you configure any of those).

http://www.postfix.org/postconf.5.html#receive_override_options

--
Matus UHLAR - fantomas, uh...@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
Fucking windows! Bring Bill Gates! (Southpark the movie)


Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-04 Thread Steve Dondley
>
>
>
> >-o content_filter=spamassassin
>
> the question is, how does spamassassin push mail back to postfix.


I have no earthly idea. Not sure how SA works, exactly. And it makes me
wonder if I'm breaking spam assassin by adding

-o receive_override_options=no_address_mappings

to my configuration. How would I figure that out?


Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-04 Thread Matus UHLAR - fantomas

On 03.03.21 18:23, Steve Dondley wrote:
>I have enabled the always_bcc setting with:
>
>always_bcc = exam...@example.org
>
>It works, but I'm getting everything three times. How do I prevent duplicates?



this can happen if you use content_filter that feeds mail back to postfix.


On 04.03.21 06:42, Steve Dondley wrote:

OK, yeah, I got spam assassin installed and have this line in
master.cf for smtp:

-o content_filter=spamassassin


the question is, how does spamassassin push mail back to postfix.

--
Matus UHLAR - fantomas, uh...@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
It's now safe to throw off your computer.


Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-04 Thread Steve Dondley
> On 03.03.21 18:23, Steve Dondley wrote:
> >I have enabled the always_bcc setting with:
> >
> >always_bcc = exam...@example.org
> >
> >It works, but I'm getting everything three times. How do I prevent 
> >duplicates?
>
> this can happen if you use content_filter that feeds mail back to postfix.

OK, yeah, I got spam assassin installed and have this line in
master.cf for smtp:

-o content_filter=spamassassin


Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-04 Thread Matus UHLAR - fantomas

On 03.03.21 18:23, Steve Dondley wrote:

I have enabled the always_bcc setting with:

always_bcc = exam...@example.org

It works, but I'm getting everything three times. How do I prevent duplicates?


this can happen if you use content_filter that feeds mail back to postfix.

in these cases, you can configure master.cf to add
-o receive_override_options=no_address_mappings
either for the incoming mail in "smtp"
of for mail that is sent by content_filter:

I personally recommend the latter: to process incoming mail with address
mappings and disabling mappings when receiving mail from filter as described
in amavis docs:

https://www.ijs.si/software/amavisd/README.postfix.html#basics_smtpd-daemon


--
Matus UHLAR - fantomas, uh...@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
REALITY.SYS corrupted. Press any key to reboot Universe.


Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-03 Thread Steve Dondley
Thanks for your help Wietse.

I had actually started reading it a few minutes ago. It's a tough read
for a new guy. I'm having to learn mostly with a lot of trial, error
and experimentation. I gotta go track down that postfix book I
downloaded a while ago.


On Wed, Mar 3, 2021 at 6:53 PM Wietse Venema  wrote:
>
> Steve Dondley:
> > OK, I found some guidance here:
> > http://www.postfix.org/ADDRESS_REWRITING_README.html
> >
> > Adding in "-o receive_override_options=no_address_mappings" to the
> > smtpd section worked.
> >
> > I really don't understand the master configuration file at all,
> > however. Is there a good basic tutorial that explains it?
>
> http://www.postfix.org/master.5.html describes the syntax of "-o
> name=value", and http://www.postfix.org/postconf.5.html describes
> the parameters themselves.
>
> Wietse
>
> > On Wed, Mar 3, 2021 at 6:23 PM Steve Dondley  wrote:
> > >
> > > I have enabled the always_bcc setting with:
> > >
> > > always_bcc = exam...@example.org
> > >
> > > It works, but I'm getting everything three times. How do I prevent 
> > > duplicates?
> >
> >
> >
> > --
> > Prometheus Labor Communications, Inc.
> > http://prometheuslabor.com
> > 413-572-1300
> >
> > UnionConnect Phone App for Labor Unions
> > http://unionconnect.com
> >



--
Prometheus Labor Communications, Inc.
http://prometheuslabor.com
413-572-1300

UnionConnect Phone App for Labor Unions
http://unionconnect.com


Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-03 Thread Wietse Venema
Steve Dondley:
> OK, I found some guidance here:
> http://www.postfix.org/ADDRESS_REWRITING_README.html
> 
> Adding in "-o receive_override_options=no_address_mappings" to the
> smtpd section worked.
> 
> I really don't understand the master configuration file at all,
> however. Is there a good basic tutorial that explains it?

http://www.postfix.org/master.5.html describes the syntax of "-o
name=value", and http://www.postfix.org/postconf.5.html describes
the parameters themselves.

Wietse

> On Wed, Mar 3, 2021 at 6:23 PM Steve Dondley  wrote:
> >
> > I have enabled the always_bcc setting with:
> >
> > always_bcc = exam...@example.org
> >
> > It works, but I'm getting everything three times. How do I prevent 
> > duplicates?
> 
> 
> 
> -- 
> Prometheus Labor Communications, Inc.
> http://prometheuslabor.com
> 413-572-1300
> 
> UnionConnect Phone App for Labor Unions
> http://unionconnect.com
> 


Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-03 Thread Wietse Venema
Steve Dondley:
> I have enabled the always_bcc setting with:
> 
> always_bcc = exam...@example.org
> 
> It works, but I'm getting everything three times. How do I prevent duplicates?

Postfix by default deduplicates if one message has multiple identical
recipients. However Postfix cannot deduplicate different queue files
that have the same content.

So if Postfix receives three messages, and you add an always_bcc
record to all of them, then the always_bcc address will receive
three copies.

Look at the Received: headers in the duplicates and see if they
followed different paths. The maillog file may also provide relevant
details.

Wietse


Re: How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-03 Thread Steve Dondley
OK, I found some guidance here:
http://www.postfix.org/ADDRESS_REWRITING_README.html

Adding in "-o receive_override_options=no_address_mappings" to the
smtpd section worked.

I really don't understand the master configuration file at all,
however. Is there a good basic tutorial that explains it?

On Wed, Mar 3, 2021 at 6:23 PM Steve Dondley  wrote:
>
> I have enabled the always_bcc setting with:
>
> always_bcc = exam...@example.org
>
> It works, but I'm getting everything three times. How do I prevent duplicates?



-- 
Prometheus Labor Communications, Inc.
http://prometheuslabor.com
413-572-1300

UnionConnect Phone App for Labor Unions
http://unionconnect.com


How do I stop getting multiple copies of emails from "always_bcc" option?

2021-03-03 Thread Steve Dondley
I have enabled the always_bcc setting with:

always_bcc = exam...@example.org

It works, but I'm getting everything three times. How do I prevent duplicates?


always_bcc and default_destination_concurrency_limit

2021-01-08 Thread Alex
Hi,

I'm trying to use postfix-3.5.7 to throttle email to freemail domains
like gmail and yahoo, but having some problems. I'm able to throttle
it for users @gmail.com, but not for domains that use google as their
MX because the recipient is not @gmail.com, for example.

For this reason, I thought I could just generally throttle the default
delivery, and create another delivery agent that increases concurrency
for domains I know to be able to manage what is normally the default.
Hopefully that makes sense.

The problem is that I'm using always_bcc to deliver a copy of each
email locally, and by modifying the default delivery agent:

default_destination_concurrency_limit = 4
default_destination_rate_delay = 6s
default_extra_recipient_limit = 10

This results in emails to my always_bcc user sitting in the active
queue for an excessive period. I tried to explicitly define this
recipient to be processed by the local delivery agent, but that didn't
work.

/mail-archive\@myhost.example.com$/ local:

/etc/postfix/main.cf:
gmail_initial_destination_concurrency = 1
gmail_destination_concurrency_limit = 4
gmail_destination_recipient_limit = 15
gmail_connect_timeout=3s
gmail_connection_cache_on_demand=no

/etc/postfix/master.cf:
gmail  unix - - n - - smtp
-o syslog_name=postfix-gmail
-o smtp_connect_timeout=$gmail_connect_timeout
-o smtp_connection_cache_on_demand=$gmail_connection_cache_on_demand

Thanks,
Alex


Re: Always_bcc with aliases

2020-03-20 Thread Wietse Venema
Prince Law Offices:
> Thanks for the response, and sorry for my delayed reaction.  
> 
> I understand that always_bcc should send a copy to the address
> indicated or the alias of the address indicated.  My situation is
> slightly different.  It?s the initial recipient (the To:) that is
> aliased AND uses a transport to execute an external app.  The app
> is expecting the alias, and that all works fine.  The app is happy.
> My problem is that I also want to bcc that incoming email to an
> aliased address.  That doesn?t seem to happen.


The code suggests otherwise:

cleanup_addr_bcc() calls cleanup_out_recipient() which calls
cleanup_map1n() which does the virtual alias expansion.

However the aliasing does not happen when you disabled address
mapping, as is done before or after a content with
"receive_override_options = no_address_mappings".

Wietse


Re: Always_bcc with aliases

2020-03-20 Thread Prince Law Offices
Thanks for the response, and sorry for my delayed reaction.  

I understand that always_bcc should send a copy to the address indicated or the 
alias of the address indicated.  My situation is slightly different.  It’s the 
initial recipient (the To:) that is aliased AND uses a transport to execute an 
external app.  The app is expecting the alias, and that all works fine.  The 
app is happy.  My problem is that I also want to bcc that incoming email to an 
aliased address.  That doesn’t seem to happen.  

By-the-by, my app also generates a new email to be sent to an employee (without 
any aliases) and that always_bcc works fine.

Let me try another example.  Email is addressed to i...@mycompany.com 
<mailto:j...@mycompany.com>.  All email addressed to i...@mycompany.com 
<mailto:j...@mycompany.com> is aliased to j...@mycompany.com 
<mailto:j...@mycompany.com>.  There is also a transport set up to send email 
addressed to j...@mycompany.com <mailto:j...@mycompany.com> via pipe in 
master.cf to my application.  I would also like a copy of the email to 
i...@mycompany.com <mailto:i...@mycompany.com> to go to an archive mailbox.  
Always_bcc is not functioning on the incoming email to i...@mycompany.com 
<mailto:i...@mycompany.com>.

Is there any way to log always_bcc actions?  I know adding it to the header 
defeats the purpose of the bcc.  
Does that also apply to the server’s log?


> On Mar 15, 2020, at 3:10 PM, Wietse Venema  wrote:
> 
> always_bcc is implemented upon receving email, so that
> 
>always_bcc = arch...@example.com
> 
> will send a copy to arch...@example.com, unless you have aliased
> that to something else. In that case, your BCC copy will be sent
> there.
> 
> For example if you have a wild-card alias
> 
>   @example.com blah
> 
> Then your BCC copy will be sent to blah, unless you also add an 1:1
> alias to prevent that:
> 
># Everything aliased to blah
>@example.com blah
># Except for arch...@example.com
>arch...@example.comarch...@example.com
> 
>   Wietse



Re: Always_bcc with aliases

2020-03-15 Thread Wietse Venema
always_bcc is implemented upon receving email, so that

always_bcc = arch...@example.com

will send a copy to arch...@example.com, unless you have aliased
that to something else. In that case, your BCC copy will be sent
there.

For example if you have a wild-card alias

@example.com blah

Then your BCC copy will be sent to blah, unless you also add an 1:1
alias to prevent that:

# Everything aliased to blah
@example.com blah
# Except for arch...@example.com
arch...@example.com arch...@example.com

Wietse


  1   2   3   >