Postfix 2.9.3 + milter, first header line missing in header callback

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Postfix 2.9.3 + milter, first header line missing in header callback

Markus Petri-3
Hi,

I wrote a small milter to archive incoming emails. While testing I
noticed, that I never got the Received line inserted by the local
Postfix itself. A tcpdump of the milter traffic doesn't show the
Received line too. Out of curiosity I prepended a header line with
smtpd_sender_restrictions

/./ PREPEND X-MTA: Local

and checked again, whether I could see this X-MTA line in the milter
header callback. I did not, but to my surprise the previously missing
Received line was there. Removing the X-MTA PREPEND made the Received
line dissappear again.

So it seems to me, that the milter client eats the first header line
and the milter does not see it.

I tested Postfix 2.9.3 (Debian package) and Postfix 2.9.3 compiled
from source. Both show the same behaviour.

Here my postconf -n output and some example data (swaks test email,
the email in mailbox, output of test-milter logging header callback):


postconf -n output:

alias_database = hash:/etc/postfix/aliases
alias_maps = hash:/etc/postfix/aliases
append_dot_mydomain = no
biff = no
body_checks = pcre:/etc/postfix/body_checks.pcre
bounce_size_limit = 1
config_directory = /etc/postfix
data_directory = /var/lib/postfix
disable_dns_lookups = yes
disable_vrfy_command = yes
frozen_delivered_to = no
header_checks = pcre:/etc/postfix/header_checks.pcre
inet_interfaces = localhost
inet_protocols = ipv4,ipv6
local_header_rewrite_clients = permit_mynetworks permit_sasl_authenticated
mail_owner = postfix
mailbox_command = /usr/bin/maildrop -d "$USER" -f "$SENDER"
mailbox_size_limit = 0
message_size_limit = 35000000
mime_header_checks =
mydestination = localhost localhost.example.com $myhostname
mydomain = $myhostname
myhostname = legolas.example.com
mynetworks = 127.0.0.1 [::1] 192.168.128.9
mynetworks_style = host
myorigin = $myhostname
nested_header_checks =
owner_request_special = no
queue_directory = /var/spool/postfix
recipient_delimiter = +
sender_dependent_default_transport_maps = pcre:/etc/postfix/sender_transport.pcre
setgid_group = postdrop
smtp_generic_maps = pcre:/etc/postfix/generic.pcre
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sender_dependent_authentication = yes
smtp_use_tls = yes
smtpd_milters = inet:127.0.0.1:5555
smtpd_recipient_restrictions = permit_mynetworks permit_sasl_authenticated reject_unauth_destination reject_unlisted_recipient
smtpd_sender_restrictions = pcre:/etc/postfix/inc_head.pcre
soft_bounce = no
transport_maps = hash:/etc/postfix/transport
virtual_alias_maps = pcre:/etc/postfix/virtual.pcre



input (swaks):

=== Trying localhost:25...
=== Connected to localhost.
<-  220 legolas.example.com ESMTP Postfix
 -> EHLO legolas.example.com
<-  250-legolas.example.com
<-  250-PIPELINING
<-  250-SIZE 35000000
<-  250-ETRN
<-  250-ENHANCEDSTATUSCODES
<-  250-8BITMIME
<-  250 DSN
 -> MAIL FROM:<[hidden email]>
<-  250 2.1.0 Ok
 -> RCPT TO:<[hidden email]>
<-  250 2.1.5 Ok
 -> DATA
<-  354 End data with <CR><LF>.<CR><LF>
 -> Date: Thu, 05 Jul 2012 20:20:55 +0200
 -> To: [hidden email]
 -> From: [hidden email]
 -> Subject: test Thu, 05 Jul 2012 20:20:55 +0200
 -> X-Mailer: swaks v20120320.0 jetmore.org/john/code/swaks/
 ->
 -> This is a test mailing
 ->
 -> .
<-  250 2.0.0 Ok: queued as 91A53257F4
 -> QUIT
<-  221 2.0.0 Bye
=== Connection closed with remote host.



output (in mailbox):

Return-Path: <[hidden email]>
X-Original-To: [hidden email]
Delivered-To: [hidden email]
X-MTA: Local
Received: from legolas.example.com (localhost [127.0.0.1])
        by legolas.example.com (Postfix) with ESMTP id 91A53257F4
        for <[hidden email]>; Thu,  5 Jul 2012 20:20:55 +0200 (CEST)
Date: Thu, 05 Jul 2012 20:20:55 +0200
To: [hidden email]
From: [hidden email]
Subject: test Thu, 05 Jul 2012 20:20:55 +0200
X-Mailer: swaks v20120320.0 jetmore.org/john/code/swaks/

This is a test mailing



output (perl testmilter, header callback):

--> in header callback
Received: from legolas.example.com (localhost [127.0.0.1])
        by legolas.example.com (Postfix) with ESMTP id 91A53257F4
        for <[hidden email]>; Thu,  5 Jul 2012 20:20:55 +0200 (CEST)
--> in header callback
Date: Thu, 05 Jul 2012 20:20:55 +0200
--> in header callback
To: [hidden email]
--> in header callback
From: [hidden email]
--> in header callback
Subject: test Thu, 05 Jul 2012 20:20:55 +0200
--> in header callback
X-Mailer: swaks v20120320.0 jetmore.org/john/code/swaks/
Reply | Threaded
Open this post in threaded view
|

Re: Postfix 2.9.3 + milter, first header line missing in header callback

Wietse Venema
Markus Petri:
> Hi,
>
> I wrote a small milter to archive incoming emails. While testing I
> noticed, that I never got the Received line inserted by the local
> Postfix itself. A tcpdump of the milter traffic doesn't show the

This is for Sendmail compatibility. When I implemented Postfix
Milter support, Sendmail did not give the "first" header to the
Milter application, and therefore Postfix couldn't either. The PREPEND
feature was introduced several releases before Milter support, so
I could not change the order of Received: and PREPEND headers without
breaking compatibility or making Postfix harder to use.

Regardless of the merits of Sendmail's choice, it is better that
Milter programs produce consistent results across MTAs.

The rules for header manipulation have similar limitations.  Again,
that wasn't a choice for me to make.

        Wietse
Reply | Threaded
Open this post in threaded view
|

Re: Postfix 2.9.3 + milter, first header line missing in header callback

Bastian Blank-3
In reply to this post by Markus Petri-3
On Thu, Jul 05, 2012 at 08:56:34PM +0200, Markus Petri wrote:
> I wrote a small milter to archive incoming emails.

Use recipient_bcc_maps to archive emails.

Bastian

--
Men will always be men -- no matter where they are.
                -- Harry Mudd, "Mudd's Women", stardate 1329.8
Reply | Threaded
Open this post in threaded view
|

Re: Postfix 2.9.3 + milter, first header line missing in header callback

Michael Tokarev
On 06.07.2012 17:14, Bastian Blank wrote:
> On Thu, Jul 05, 2012 at 08:56:34PM +0200, Markus Petri wrote:
>> I wrote a small milter to archive incoming emails.
>
> Use recipient_bcc_maps to archive emails.

Or always_bcc parameter.

/mjt