On Wed, Jun 15, 2022 at 08:54:34AM -0400, Wietse Venema wrote:

> That queue ID should also show up in the 'hold' queue when you use
> the "mailq" command. Example:
> 
>     $ mailq | grep '!'
>     4LN9p23LK0zJrP1!       983 Tue Jun 14 23:31:34 u...@example.com

Alternatively, use the machine-readable JSON output from "postqueue -j":

    $ postqueue -j | jq -r '
        first(select(.queue_name == "deferred" and
                     (.queue_id | test("^[0-9A-F]+$")) and
                     (.recipients[].address | test("^.ostmaster"))))
        | .queue_id
        '
    CF6B4106ABD7

I have a "deferred" message addressed to "postmaster" and "hostmaster"
at a poorly operated domain, so the "queue_name" was "deferred".  In
your case it should be "hold".

To avoid trusting the low-privilege Postfix user to supply arguments
for commands run as root, the queue id is filtered to be of the
expected upper-case hexadecimal form.

Because the recipient test (deliberately, to make the point) matches
either recipient, to avoid reporting the same queue file multiple times
,once for each matching recipient, the select(...) is pruned to the
first match via first(select(...)).


> Use the "postsuper -H" command to release the message from quarantine.
> 
>     # postsuper -H 4LN9p23LK0zJrP1
>     $ postfix flush
>     $ grep 4LN9p23LK0zJrP1 /var/log/maillog
>     <timestamp> <host> postfix/postsuper[<pid>]: 4LN9p23LK0zJrP1:
>     released from hold

Release all quarantined mail from "harml...@example.net" to
"artl...@example.org" (and any other recipients of the same message
envelope):

    # jq -r '
        first(select(.queue_name == "hold" and
                     (.queue_id | test("^[0-9A-F]+$")) and
                     .sender == "harml...@example.net" and
                     (.recipients[].address == "artl...@example.org")))
        | .queue_id
        ' | postsuper -H hold

-- 
    Viktor.

Reply via email to