Sometimes, mails stay stuck in my postfix queue, the distant server saying "Too many connections, slow down". I already configured my postfix for specific domains to send only one mail per second, but sometimes it seems insufficient.
I know of postqueue -f
, but it send all mails at the same time and the mails stays in queue with the same status.
I would like to flush the queue of a postfix one mail at a time, let's say one mail every second (or 2, or more).
Best Answer
It's possible to flush one particular email, instead of the whole queue. If you do this for each message in turn, with a two-second sleep between messages, that should do what you ask for.
First, you need to find the queue IDs of the mails in the queue. You can get this by using the command
postqueue -p
. Here's an example output:What you need is in the first column. You can get all of the IDs by some piping through grep and cut, like so:
Now that you know how to get at the IDs, you can throw them in a bash loop with some sleep: