Re: mail-to-script messages id and from lines

2021-11-23 Thread Jürgen Weber
> The "id" line should start with tab or space. That's how Postfix creates the 
> line.

And my pipe script killed the blank.

Now the Python parser works fine.

Thanks very much for your help,
Jürgen

[('Return-Path', ''), ('X-Original-To',
'maild@my.virtual'), ('Delivered-To', 'ma...@host.my.tld'),
('Received', 'by host.my.tld (Postfix, from userid 1001)\n  id
D3DFD783; Sun, 21 Nov 2021 19:11:19 +0100 (CET)'), ('To',
'maild@my.virtual'), ('Subject', 's1'), ('Message-Id',
'<20211121181119.d3dfd...@host.my.tld>'), ('Date', 'Sun, 21 Nov 2021
19:11:19 +0100 (CET)'), ('From', 'Jürgen Weber
')]


Am Mi., 24. Nov. 2021 um 00:17 Uhr schrieb Wietse Venema :
>
> J?rgen Weber:
> > From webe...@host.my.tld  Sun Nov 21 19:11:19 2021
> > Return-Path: 
> > X-Original-To: maild@my.virtual
> > Delivered-To: ma...@host.my.tld
> > Received: by host.my.tld (Postfix, from userid 1001)
> > id D3DFD783; Sun, 21 Nov 2021 19:11:19 +0100 (CET)
>
> The "id" line should start with tab or space. That's how
> Postfix creates the line.
>
> > To: maild@my.virtual
> > Subject: s1
> > Message-Id: <20211121181119.d3dfd...@host.my.tld>
> > Date: Sun, 21 Nov 2021 19:11:19 +0100 (CET)
> > From: J?rgen Weber 
>
> Non-ASCII header text should be encoded with RFC 2o47.
>
> > Can you prevent Postfix from adding these lines?
>
> Use egrep.
>
> If Python's email.Parser can't handle non-ASCII headers, then you
> should not use it for real email management.
>
> Wietse


Re: mail-to-script messages id and from lines

2021-11-23 Thread Scott Kitterman
On Tuesday, November 23, 2021 6:16:43 PM EST Wietse Venema wrote:
> J?rgen Weber:
> > From webe...@host.my.tld  Sun Nov 21 19:11:19 2021
> > Return-Path: 
> > X-Original-To: maild@my.virtual
> > Delivered-To: ma...@host.my.tld
> > Received: by host.my.tld (Postfix, from userid 1001)
> > id D3DFD783; Sun, 21 Nov 2021 19:11:19 +0100 (CET)
> 
> The "id" line should start with tab or space. That's how
> Postfix creates the line.
> 
> > To: maild@my.virtual
> > Subject: s1
> > Message-Id: <20211121181119.d3dfd...@host.my.tld>
> > Date: Sun, 21 Nov 2021 19:11:19 +0100 (CET)
> > From: J?rgen Weber 
> 
> Non-ASCII header text should be encoded with RFC 2o47.
> 
> > Can you prevent Postfix from adding these lines?
> 
> Use egrep.
> 
> If Python's email.Parser can't handle non-ASCII headers, then you
> should not use it for real email management.

It can.  It has trouble with non-UTF-8 if you use the string type internally.  
You have to use byte strings and not everyone does.  I think it's generally 
fine, but there are foot guns to watch out for.

Scott K




Re: mail-to-script messages id and from lines

2021-11-23 Thread Wietse Venema
J?rgen Weber:
> From webe...@host.my.tld  Sun Nov 21 19:11:19 2021
> Return-Path: 
> X-Original-To: maild@my.virtual
> Delivered-To: ma...@host.my.tld
> Received: by host.my.tld (Postfix, from userid 1001)
> id D3DFD783; Sun, 21 Nov 2021 19:11:19 +0100 (CET)

The "id" line should start with tab or space. That's how
Postfix creates the line.

> To: maild@my.virtual
> Subject: s1
> Message-Id: <20211121181119.d3dfd...@host.my.tld>
> Date: Sun, 21 Nov 2021 19:11:19 +0100 (CET)
> From: J?rgen Weber 

Non-ASCII header text should be encoded with RFC 2o47.

> Can you prevent Postfix from adding these lines?

Use egrep.

If Python's email.Parser can't handle non-ASCII headers, then you
should not use it for real email management.

Wietse


mail-to-script messages id and from lines

2021-11-23 Thread Jürgen Weber
I have Postfix (3.6.3, FreeBSD 12) forward mail for a user to a script

maild: "| /usr/local/sbin/mailsave"

The messages have From and id lines which break Python's (3.7) email.Parser

Can you prevent Postfix from adding these lines?

Thanks,
Juergen

>From webe...@host.my.tld  Sun Nov 21 19:11:19 2021
Return-Path: 
X-Original-To: maild@my.virtual
Delivered-To: ma...@host.my.tld
Received: by host.my.tld (Postfix, from userid 1001)
id D3DFD783; Sun, 21 Nov 2021 19:11:19 +0100 (CET)
To: maild@my.virtual
Subject: s1
Message-Id: <20211121181119.d3dfd...@host.my.tld>
Date: Sun, 21 Nov 2021 19:11:19 +0100 (CET)
From: Jürgen Weber 

body


Re: blocking incomming mail

2021-11-23 Thread Wietse Venema
natan:
> Hi
> I need block all in incomming to one e-mail like:
> 
> to= DISCARD
> but allow:
> from=
> 
> At the earliest level as possible only in smtpd_recipient_restrictions ?

smtpd_recipient_restrictions =
check_recipient_access inline:{
{ u...@domain.ltd = DISCARD }
} ...other stuff...

However, there is a warning in the Postfix access(5) manpage:

Note: this action currently affects all recipients of the
message. To discard only one recipient without discarding the
entire message, use the transport(5) table to direct mail to
the discard(8) service.

Wietse


blocking incomming mail

2021-11-23 Thread natan
Hi
I need block all in incomming to one e-mail like:

to= DISCARD
but allow:
from=

At the earliest level as possible only in smtpd_recipient_restrictions ?

--



Re: Whitelisting by subject

2021-11-23 Thread Wietse Venema
Lothar Schilling:
> Hi everybody,
> 
> amongst other duties I am the adminstrator of another organisation's 
> small (samba) server. Each day this server will send me its logs via 
> email. Sadly, more often than not those emails get discarded by our 
> relay server. Sometimes they fall victim to smtpd_relay_restrictions 
> (blacklisted with spamhaus), but mostly postscreen will kill them with 
> its DNS blackhole lists.
> 
> Problem is that the sending server has a dynamic IP address. So, is it 
> possible to whitelist these mails, e.g. by a concise subject, before 
> smtpd_relay_restrictions or postscreen will even get to see them?

Postscreen and smtpd_relay_restrictions ar IP-based and never see
email content. These hosts should not be exposed to any of that.

I suggest that these hosts not connect to the NTA service on port
25. Instead, they should connect to an MUA service port 587
(submission) or 465 (smtps, submissions) and authenticate with SASL
or TLS certificate. Properly configured MUA services do not use
postscreen or smtpd_relay_resitrctions.

Wietse


Whitelisting by subject

2021-11-23 Thread Lothar Schilling

Hi everybody,

amongst other duties I am the adminstrator of another organisation's 
small (samba) server. Each day this server will send me its logs via 
email. Sadly, more often than not those emails get discarded by our 
relay server. Sometimes they fall victim to smtpd_relay_restrictions 
(blacklisted with spamhaus), but mostly postscreen will kill them with 
its DNS blackhole lists.


Problem is that the sending server has a dynamic IP address. So, is it 
possible to whitelist these mails, e.g. by a concise subject, before 
smtpd_relay_restrictions or postscreen will even get to see them?


Thank you for your suggestions

Lothar Schilling