zimbra 的 postfix 隊列管理

來源:互聯網
上載者:User

標籤:postfix mail mailq

將所有要發送的郵件按寄件者排序:

[[email protected] wuxiaoyu]# cat /opt/zimbra/work/mailqbysender 

#!/bin/bash


mailq | grep ‘^[A-Z0-9]‘ | awk ‘{print $7}‘ | sort | uniq -c | sort -n

[[email protected] wuxiaoyu]# 


統計寄件者排序的top4

[[email protected] wuxiaoyu]# cat /home/sankuai/wuxiaoyu/mail.sh 

#!/bin/bash

sudo -u zimbra -i work/mailqbysender | tail -n4

m=$(sudo -u zimbra -i work/mailqbysender | tail -n1)

n=$(echo $m | awk ‘{print $2}‘)

echo $n

sudo -u zimbra -i mailq | grep $n | cut -c -12 > /tmp/_mailq.txt

[[email protected] wuxiaoyu]# 


刪除top4中最多的寄件者所發的郵件

[[email protected] wuxiaoyu]# cat /home/sankuai/wuxiaoyu/p.sh 

#!/bin/bash

cat /tmp/_mailq.txt | /opt/zimbra/postfix/sbin/postsuper -d - 


[[email protected] wuxiaoyu]# 


zimbra中的postfix

暫緩發送隊列中的問題郵件

[[email protected] incoming]# /opt/zimbra/libexec/zmqstat 

hold=0

corrupt=0

deferred=96

active=6

incoming=0

[[email protected] incoming]# which postsuper

/usr/sbin/postsuper

[[email protected] incoming]# /opt/zimbra/postfix/sbin/postsuper  -h ALL deferred

postsuper: Placed on hold: 96 messages

[[email protected] incoming]# /opt/zimbra/libexec/zmqstat 

hold=96

corrupt=0

deferred=0

active=4

incoming=0

[[email protected] incoming]# 

解除暫緩發送

[[email protected] incoming]# /opt/zimbra/postfix/sbin/postsuper  -H  ALL 

postsuper: Released from hold: 96 messages

[[email protected] incoming]# /opt/zimbra/libexec/zmqstat                 

hold=0

corrupt=0

deferred=96

active=11

incoming=0

[[email protected] incoming]#




postfix相關知識補充:

ostfix中有一套Mail Queue Management機制,所有隊列中的郵件都可以全自動的處理,但在發送大量郵件的時候,有必要對這個隊列進行手工的維護處理,比如說,刪除隊列中的郵件. 以下是一些常用的命令:

列出目前在 Mail Queue 中的郵件

mailq

刪除所有在 Queue 中的郵件

postsuper -d ALL

刪除所有正在 deferred 隊列中的郵件 (刪除曾經發送失敗的郵件 )

postsuper -d ALL deferred

刪除所有正在 deferred 隊列中的郵件 ( 可看出哪些信被刪除了 )

find /var/spool/postfix/deferred -type f -exec rm -vf /{/} /;

刪掉「三天以前」無法發送的郵件

find /var/spool/postfix/deferred -type f -mtime +3 -exec rm -f /{/} /;

列出目前所有無法發送的郵件 find /var/spool/postfix/deferred -type f -exec ls -l –time-style=+%Y-%m-%d_%H:%M:%S {} /;

刪除超過 5 天的 “defer” 佇列中的退信記錄 find /var/spool/postfix/defer -type f -mtime +5 -exec rm -f /{/} /;

預設所有跟Postfix 相關的郵件都會放在/var/spool/postfix/ 目錄下,想瞭解Postfix是如何管理隊列的,可以參考 qmgr -Postfix queue manager 的手冊.
以下是每個目錄的用途

MAIL QUEUES

* incoming 收信箱

* active 正在準備發送的郵件

* defered 無法發送的郵件,等待重發

* corrupt 無法讀取或者損壞的郵件

* hold 暫停郵件,需要手工啟動 DELIVERY STATUS REPORTS

* bounce 每一位收件者的送信狀態,記錄為什麼退信由 bounce(8) 管理

* defer 每一位收件者的寄送狀態,說明為什麼延遲由 defer(8) 管理

* trace 每一位收件者的寄送狀態資訊,說明被 Postfix 用 “sendmail -v” 或 “sendmail -bv” 命令執行的狀態由 trace(8) 管理

1. try and deliver the mail from the queue(強制發送隊列中的郵件):

$ postfix flush or $ postqueue -f

2. check mail queue size (查看隊列大小):

$ mailq | wc -l

3. list mails in queue (查看隊列中的郵件):

$ postqueue -p or $ mailq

4.put all deferred mail “on hold” so that no attempt is made to deliver it(暫緩發送隊列中的問題郵件):

$

5. release mail that was put “on hold”(解除暫緩發送):

$

6. purge all deferred emails from the queue without delivering (刪除隊列中問題的郵件):

$ postsuper -d ALL deferred $ find /var/spool/postfix/deferred -type f -exec rm -vf {} \;

7. purge specific email from the queue by specifying its message ID (按郵件ID刪除隊列中的郵件):

$ postsuper -d 0C0FF240F2

8. 刪除已經三天未發出的郵件

$ find /var/spool/postfix/deferred -type f -mtime +3 -exec rm -f {} \;

9. 列出所有問題郵件

$ find /var/spool/postfix/deferred -type f \ -exec ls -l --time-style=+%Y-%m-%d_%H:%M:%S {} \;

10. 刪除超過5天的問題郵件的退信記錄

$ find /var/spool/postfix/defer -type f -mtime +5 -exec rm -f {} \;

11. 複雜用法:利用grep得到特定的郵件ID,再刪除,如:

$ mailq | grep -B 1 "[email protected]" | cut -f 1 -d ! > deletionIDs" $ cat deletionIDs | postsuper -d -


zimbra 的 postfix 隊列管理

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.