大网数据广告活动
服务器运维问答

How to flush postfix queue one mail at a time?

· 52CE 我爱测

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 insuffici…

问题原文

原帖链接 · vincent.m · CC BY-SA 3.0

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).

已采纳解答

原帖链接 · Jenny D · CC BY-SA 3.0

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:

-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
6777D6E1E      3517 Mon Jan 25 03:03:02  [email omitted]
                                         [email omitted]

69F6471CA      2820 Tue Jan 26 03:24:17  [email omitted]
                                         [email omitted]

What you need is in the first column. You can get all of the IDs by some piping through grep and cut, like so:

[jenny@sameen ~]$ postqueue -p | grep -v ^- | grep -v "(" | cut -d' ' -f1 |grep -e [[:alnum:]]
6777D6E1E
69F6471CA

Now that you know how to get at the IDs, you can throw them in a bash loop with some sleep:

[jenny@sameen ~]$ for ID in `postqueue -p | grep -v ^- | grep -v "(" | cut -d' ' -f1 |grep -e [[:alnum:]] `; do postqueue -i $ID; sleep 2; done

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-01-29)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。