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

2021-02-12 Thread Viktor Dukhovni
> On Feb 12, 2021, at 2:43 PM, Wietse Venema  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,  not followed by ,  not preceeded by , 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 == "j...@example.org") | .queue_id)' |
  postsuper -H -

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

-- 
Viktor.



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

2021-02-12 Thread 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,  not followed by ,  not preceeded by , and
so on.

Wietse


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

2021-02-11 Thread 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 :-)


Cheers


tobi





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

2021-02-11 Thread 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.


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

2021-02-11 Thread 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