Mails in active queue are never tried to be sent

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

Re: Inserting a unique ID into the email header with Postfix alone

/dev/rob0
On Sat, Mar 19, 2016 at 03:34:28PM +0100, Istvan Prosinger wrote:

> I've tried what you ask, this is what I got:
>
> [root@email ~]# postmap -h -q - pcre:/etc/postfix/stamp.pcre < testheader
>
> Received: from localhost (localhost [127.0.0.1])
>         by email-test.server.com (Postfix) with ESMTP id 3qRyhf4pqCzKmYs
>         for <[hidden email]>; Sat, 19 Mar 2016 06:17:54 -0400
> (EDT) Prepend X-DIYL-3qRyhf4pqCzKmYs
> Received: from knox.prosinger.net (knox.prosinger.net [5.44.101.107])
>         by email-test.server.com (Postfix) with ESMTPS id 3qRyhf0ChgzKmYq
>         for <[hidden email]>; Sat, 19 Mar 2016 06:17:52 -0400
> (EDT) Prepend X-DIYL-3qRyhf0ChgzKmYq
>
>
> I think that this means two hits. If so, what comes to my mind is
> that these headers are not there yet, in the moment when the
> stamper.pcre is called.

You apparently are using a post-queue content filter.

If you want the post-filter queue ID as your header, adjust the
expression to include "localhost \(localhost \[127\.0\.0\.1\]\)".

If you want the pre-filter queue ID as your header, exclude that part
from your expression.  Note, that's not foolproof, if you happen to
have something on localhost sending mail.

Perhaps a better idea is: only apply these header_checks before (or
after?) the filter.  See:

postconf.5.html#receive_override_options
postconf.5.html#cleanup_service_name
--
  http://rob0.nodns4.us/
  Offlist GMX mail is seen only if "/dev/rob0" is in the Subject:
Reply | Threaded
Open this post in threaded view
|

Re: Inserting a unique ID into the email header with Postfix alone

Wietse Venema
In reply to this post by Istvan Prosinger
Istvan Prosinger:

> [root@email ~]# postmap -h -q - pcre:/etc/postfix/stamp.pcre < testheader
>
> Received: from localhost (localhost [127.0.0.1])
>          by email-test.server.com (Postfix) with ESMTP id 3qRyhf4pqCzKmYs
>          for <[hidden email]>; Sat, 19 Mar 2016 06:17:54
> -0400 (EDT) Prepend X-DIYL-3qRyhf4pqCzKmYs
> Received: from knox.prosinger.net (knox.prosinger.net [5.44.101.107])
>          by email-test.server.com (Postfix) with ESMTPS id 3qRyhf0ChgzKmYq
>          for <[hidden email]>; Sat, 19 Mar 2016 06:17:52
> -0400 (EDT) Prepend X-DIYL-3qRyhf0ChgzKmYq
>
> I think that this means two hits.

Two Received headers match the pattern, each returns a prepend action.

> If so, what comes to my mind is that these headers are not there
> yet, in the moment when the stamper.pcre is called.

Postfix's own Received: header is prepended by smtpd(8) when receiving
mail from the network:

    Received: from client-info by server-info ...

this happens BEFORE the cleanup server does the header_checks matches.

Postfix's own Received: header is prepended by pickup(8) with mail
from /usr/sbin/sendmail:

    Received: by server-info ...

this happens BEFORE the cleanup server does the header_checks matches.

        Wietse
Reply | Threaded
Open this post in threaded view
|

Re: Inserting a unique ID into the email header with Postfix alone

Istvan Prosinger


On 19.3.2016 16:02, Wietse Venema wrote:

> Istvan Prosinger:
>> [root@email ~]# postmap -h -q - pcre:/etc/postfix/stamp.pcre < testheader
>>
>> Received: from localhost (localhost [127.0.0.1])
>>           by email-test.server.com (Postfix) with ESMTP id 3qRyhf4pqCzKmYs
>>           for <[hidden email]>; Sat, 19 Mar 2016 06:17:54
>> -0400 (EDT) Prepend X-DIYL-3qRyhf4pqCzKmYs
>> Received: from knox.prosinger.net (knox.prosinger.net [5.44.101.107])
>>           by email-test.server.com (Postfix) with ESMTPS id 3qRyhf0ChgzKmYq
>>           for <[hidden email]>; Sat, 19 Mar 2016 06:17:52
>> -0400 (EDT) Prepend X-DIYL-3qRyhf0ChgzKmYq
>>
>> I think that this means two hits.
>
> Two Received headers match the pattern, each returns a prepend action.
>
>> If so, what comes to my mind is that these headers are not there
>> yet, in the moment when the stamper.pcre is called.
>
> Postfix's own Received: header is prepended by smtpd(8) when receiving
> mail from the network:
>
>      Received: from client-info by server-info ...
>
> this happens BEFORE the cleanup server does the header_checks matches.
>
> Postfix's own Received: header is prepended by pickup(8) with mail
> from /usr/sbin/sendmail:
>
>      Received: by server-info ...
>
> this happens BEFORE the cleanup server does the header_checks matches.
>
> Wietse
>

Yessss...but I was not doing header checks, I was calling to it in
smtpd_recipient_restrictions

It works now.
I've modified the pattern to
/Received:\sfrom\slocalhost\s\S+\s\S+\s+by\semail-test\.diylettering\.com\s\S+\s\S+\s\S+\s+id\s(\S+)/
Prepend X-DIYL: $1

It does not hit twice now.

I had to remove the anchoring at start (as you originally suggested),
because for some reason it didn't hit then.

Thanks a lot, I owe you another beer
Reply | Threaded
Open this post in threaded view
|

Re: Inserting a unique ID into the email header with Postfix alone

Istvan Prosinger
In reply to this post by /dev/rob0


On 19.3.2016 15:53, /dev/rob0 wrote:

> On Sat, Mar 19, 2016 at 03:34:28PM +0100, Istvan Prosinger wrote:
>> I've tried what you ask, this is what I got:
>>
>> [root@email ~]# postmap -h -q - pcre:/etc/postfix/stamp.pcre < testheader
>>
>> Received: from localhost (localhost [127.0.0.1])
>>          by email-test.server.com (Postfix) with ESMTP id 3qRyhf4pqCzKmYs
>>          for <[hidden email]>; Sat, 19 Mar 2016 06:17:54 -0400
>> (EDT) Prepend X-DIYL-3qRyhf4pqCzKmYs
>> Received: from knox.prosinger.net (knox.prosinger.net [5.44.101.107])
>>          by email-test.server.com (Postfix) with ESMTPS id 3qRyhf0ChgzKmYq
>>          for <[hidden email]>; Sat, 19 Mar 2016 06:17:52 -0400
>> (EDT) Prepend X-DIYL-3qRyhf0ChgzKmYq
>>
>>
>> I think that this means two hits. If so, what comes to my mind is
>> that these headers are not there yet, in the moment when the
>> stamper.pcre is called.
>
> You apparently are using a post-queue content filter.
>
> If you want the post-filter queue ID as your header, adjust the
> expression to include "localhost \(localhost \[127\.0\.0\.1\]\)".
>
> If you want the pre-filter queue ID as your header, exclude that part
> from your expression.  Note, that's not foolproof, if you happen to
> have something on localhost sending mail.
>
> Perhaps a better idea is: only apply these header_checks before (or
> after?) the filter.  See:
>
> postconf.5.html#receive_override_options
> postconf.5.html#cleanup_service_name
>

Thanks for the effort. At that stage the only intportant thing was to
make the pattern the simplest possibble so I can see how it works, I
have modified it similar to your suggestion now as it started working.

Istvan
Reply | Threaded
Open this post in threaded view
|

Re: Inserting a unique ID into the email header with Postfix alone

Rich Wales
Please also note that adding something like this onto the end of a
"Received:" header line will break the syntax.  There isn't supposed to
be anything extra after the date/time stamp in a "Received:" line.  If
you feel you need to do this anyway, please consider enclosing your new
"unique ID" info in parentheses so it will look like a comment.

Rich Wales
[hidden email]
12