Possible to "import" a file into postfix queue?

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

Possible to "import" a file into postfix queue?

Tobi
Hi all

we have a very strange issue with our postfix and its external
content-filter. To debug this we wanted to take an affected
message (postcat -bhq QID >/tmp/file) and use swaks with --data command
to send it again to postfix and through the content filter. But the
swaks message
does NOT trigger our issue and therefore is properly processed.
So we cannot reproduce it over swaks but see in postfix logs that every
try from postfix to deliver the message to the filter gets 450 from
filter. This 450 is intentional as we have some very rare cornercases
where mail gets broken somewhere in the content filter, so to avoid this
cases our filter returns 450 to postfix for such mail.

So we thought it could be possible to somehow "import" such an affected
message directly into postfix queue to leave out swaks which may fix
something in the message. Is there such a postfix command to "import" a
file as message directly into postfix queues?


Thanks for any idea as we really need to be able to reproduce it or else
debugging will be very hard :-)
Cheers


tobi



Reply | Threaded
Open this post in threaded view
|

Re: Possible to "import" a file into postfix queue?

Wietse Venema
Tobi:
> So we thought it could be possible to somehow "import" such an affected
> message directly into postfix queue to leave out swaks which may fix
> something in the message. Is there such a postfix command to "import" a
> file as message directly into postfix queues?

sendmail -f sender recipient... < file

        Wietse
Reply | Threaded
Open this post in threaded view
|

Re: Possible to "import" a file into postfix queue?

Viktor Dukhovni
On Thu, Feb 11, 2021 at 07:49:30AM -0500, Wietse Venema wrote:

> > So we thought it could be possible to somehow "import" such an affected
> > message directly into postfix queue to leave out swaks which may fix
> > something in the message. Is there such a postfix command to "import" a
> > file as message directly into postfix queues?
>
> sendmail -f sender recipient... < file

Make that:

    sendmail -i -f "sender" -- recipient... < file

just in case:

    * The file contains lines starting with "."

    * If the sender is expanded from a variable, make sure
      to double-quote it, and use: '-f "$sender"', rather
      than '-f"$sender"', just in case the sender address is empty.

    * The first recipient address starts with a "-"
      - Such a recipient is bounced, unless "allow_min_user"
        is changed. from its default value.

--
    Viktor.
Reply | Threaded
Open this post in threaded view
|

Re: Possible to "import" a file into postfix queue?

Tobi
In reply to this post by Wietse Venema
Wietse,

On 2/11/21 1:49 PM, Wietse Venema wrote:
> sendmail -f sender recipient... < file

We could debug and solve the issue just wonder for next time: does
delivery via sendmail command not change the msg by one bit? Especially
no new or changed headers. Because we found our problem to be the exact
position of a \r\n If this is placed one bit more left or right the
error did not occur. That's why we could not reproduce it via swaks
--data @/file as this adds at least one header which then pushed the
problematic \r\n to an UN-problematic position.
Anyway the error was in our external content filter and is fixed now.
Was an error that had been undetected in our content-filter for more
than 10 years :-)


Cheers


tobi



Reply | Threaded
Open this post in threaded view
|

Re: Possible to "import" a file into postfix queue?

Wietse Venema
Tobi:

> Wietse,
>
> On 2/11/21 1:49 PM, Wietse Venema wrote:
> > sendmail -f sender recipient... < file
>
> We could debug and solve the issue just wonder for next time: does
> delivery via sendmail command not change the msg by one bit? Especially
> no new or changed headers. Because we found our problem to be the exact
> position of a \r\n If this is placed one bit more left or right the
> error did not occur. That's why we could not reproduce it via swaks
> --data @/file as this adds at least one header which then pushed the
> problematic \r\n to an UN-problematic position.
> Anyway the error was in our external content filter and is fixed now.
> Was an error that had been undetected in our content-filter for more
> than 10 years :-)

sendmail -G -i -f "sender" -- recipient... < file

The -G will prevent Postfix from rewriting/adding message headers.
It will still prepend a Received: header, but if that breaks DKIM,
then the sender is at fault.

However, Postfix behavior is defined only for properly formed email.
There is no warranty for messages with lines that exceeed protocol
limits, <CR> not followed by <LF>, <LF> not preceeded by <CR>, and
so on.

        Wietse
Reply | Threaded
Open this post in threaded view
|

Re: Possible to "import" a file into postfix queue?

Viktor Dukhovni
> On Feb 12, 2021, at 2:43 PM, Wietse Venema <[hidden email]> wrote:
>
> sendmail -G -i -f "sender" -- recipient... < file
>
> The -G will prevent Postfix from rewriting/adding message headers.
> It will still prepend a Received: header, but if that breaks DKIM,
> then the sender is at fault.
>
> However, Postfix behavior is defined only for properly formed email.
> There is no warranty for messages with lines that exceeed protocol
> limits, <CR> not followed by <LF>, <LF> not preceeded by <CR>, and
> so on.

The OP mentioned starting with a queue file, and using "postcat -ebh"
to extract its content.  With a queue file in hand, one can copy it
into the "hold" queue (owner:group "postfix:postfix", mode 0700) and
then (assuming nothing else is on "hold"):

        # postfix stop
        # postsuper -s
        # postfix start
        # postsuper -H ALL

If there multiple messages on hold, release just the desired one with:

  # postqueue -j |
      jq 'select(.sender == "[hidden email]") | .queue_id)' |
      postsuper -H -

Adjust the jq "select" condition as appropriate.  Releasing a queue
file from hold does not modify its content.

--
        Viktor.