茫茫網海中的冷日
         
茫茫網海中的冷日
發生過的事,不可能遺忘,只是想不起來而已!
 恭喜您是本站第 1730223 位訪客!  登入  | 註冊
主選單

Google 自訂搜尋

Goole 廣告

隨機相片
IMG_0026.jpg

授權條款

使用者登入
使用者名稱:

密碼:


忘了密碼?

現在就註冊!

小企鵝開談 : [分享]Postfix Mail Queue 管理

發表者 討論內容
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15773
[分享]Postfix Mail Queue 管理
Postfix Mail Queue 管理

Friday, March 07, 2008

Postfix Mail Queue 管理比 sendmail 簡單許多

顯示 mail queue:
postqueue -p


mailq

Queue_ID 後面有 * 號的 代表在 active queue 的信件, ! 號代表在 hold queue 的信件。

顯示信件內容:
postcat -q Queue_ID


刪除信件
單一信件
postsuper -d Queue_ID

全部刪除
postsuper -d ALL

扣住信件
postsuper -h Queue_ID

回覆
postsuper -H Queue_ID

重進排程
postsuper -r Queue_ID
postsuper -r ALL

掃清信件
postqueue -f (全部)

postqueue -s 主機名稱(by domain name)



原文出處:Acty Blog: Postfix Mail Queue 管理
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15773
[分享]Postfix Mail Queue - 一些簡單的管理指令
Postfix Mail Queue - 一些簡單的管理指令

在 UNIX 的寄信程式不論是 Sendmail 或是 Postfix 都有處理「當信件無法即時寄出」的方法,簡單的來說就是 Mail Queue (郵件佇列),底下就簡單的來說說一些指令,怎麼來觀看並處理 Mail Queue.

※ 查看卡在 mail queue 的信件 ※※※
mailq
postqueue -p

※ Mail Queue 所在的目錄 ※※※
/var/spool/mqueue
/var/spool/postfix

-- 底下列出 postfix 的子目錄

 》active
  目前正在準備發送的信件。(在 message id 後會多加一個 * 號)
Messages that the queue manager has opened for delivery. Only a limited number of messages is allowed to enter the active queue (leaky bucket strategy, for a fixed delivery rate).

 》bounce
  每一位收件者的傳送狀態,並記載為何會被退信
Per-recipient status information about why mail is bounced. These files are maintained by the bounce(8) daemon.

 》corrupt
  信件損毀導致無法傳送的信件
Unreadable or damaged queue files are moved here for inspection.

 》defer
  暫時無法被傳送的信件,並記載為何會被延遲傳送。這種情形最常發生在你的 Mail Server 被列入灰名單(GrayList)的時候,你會看到訊息為「 Your access to this mail system has been rejected due to the sending MTA's poor reputation. If you believe that this failure is in error, please contact the intended recipient via alternate means.」
Per-recipient status information about why mail is delayed. These files are maintained by the defer(8) daemon.

 》deferred
  無法被傳送的信件會放置在此目錄,但 Mail Server 還是會嘗試幫你繼續送,只是必須等 Backoff time。
Mail that could not be delivered upon the first attempt. The queue manager implements exponential backoff by doubling the time between delivery attempts.

 》hold
  被暫時停止發送的信件,如要發送出去,需要由手動(在 message id 後會多加一個 ! 號)
Messages that are kept "on hold" are kept here until someone sets them free.

 》incoming
  從外部或本地寄送到本機的信件。
Inbound mail from the network, or mail picked up by the local pickup(8) daemon from the maildrop directory.

※ 刪除所有在 Mail Queue 中所有的信件 ※※※
rm /var/spool/mqueue
postsuper -d ALL

不建議這麼做,除非你真的清楚知道你不要所有的信件!

※ 刪除所有在 deferred 狀態的信件 ※※※

因為 /var/spool/postfix/deferred 目錄下尚有 0~F 的子目錄,所以不好用 rm 一次將他清空,故系統有提供指令方式幫助你清理 deferred 下的信件
1. postsuper -d ALL deferred

後面帶的 deferred 是 queue_id ,所以你也可以用這個方法來清除其他的 queue
2. find /var/spool/postfix/deferred -type f -exec rm -vf \{\} \;

這個方法是用 find 找出該目錄下所有的檔案,找到後丟給後面的 rm 去做刪除的動作。
3. find /var/spool/postfix/deferred/  -type f -exec mv -vf \{\} /backup/mqueue/deferred/ \;

小弟建議用這個方法!這方法同第二種,只不過他不直接殺,而是將 deferred 的信件搬移到你指定的目錄去,例如例子中的 /backup/mqueue/deferred/,萬一有啥問題還可以救回來。(註:最後的 \; 不能省略唷!)


※ 刪除過了 5天仍被放在 deferred 還是寄不出去的信件 ※※※
1.  find /var/spool/postfix/deferred -type f -mtime +5 -exec rm -f \{\} \;
2.  find /var/spool/postfix/deferred -type f -mtime +5 -exec mv -vf \{\} /backup/mqueue/deferred/ \;

※ 刪除來自於 xxx@123.com 的信件 ※※※
通常我們都會開放「認證」的使用者在單位以外的地方,透過 mail server 發送信件,但萬一某個使用者帳號被盜用後,這個方便將是非常大的傷害,你會發現你的 mail queue 裡怎麼會有那麼多,不是自己 domain e-mail 所發出的信件。

刪除特定 e-mail 寄送的信件
mailq | grep "xxx@123.com" | cut -d " " -f1 | cut -d’*’ -f1 | postsuper -d -

--------------------------------------------------------------------------------------
mailq 列出 queue
grep 找特定人事
cut -d" " -f1 取出第一個欄位 message_id
cut -d"*" -f1 去掉星號 * (因為若該訊息是在 active queue 會多個 *)
postsuper -d - 刪除前面所取出來的 message_id

刪除特定文字的訊息
/usr/sbin/postqueue -p | grep "MAILER-DAEMON" | cut -d " " -f1 | cut -d"*" -f1 | /usr/sbin/postsuper -d -

-------------------------------------------------------------------------------------

※ qmgr 是postfix 處理 mail queue 的 daemon ※※※
說明請看 http://www.postfix.org/qmgr.8.html


原文出處:Postfix Mail Queue - 一些簡單的管理指令 @ 黃昏的甘蔗 :: 隨意窩 Xuite日誌
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15773
[分享]Postfix mail queue command
Postfix mail queue command
張貼者: 『蘋』民 於 下午3:06

在 Postfix 中有一套 Mail Queue Management 機制,所有郵件都可以全自動的處理,

但在發送大量郵件時,有些必要的維護就可能就有需要手動處理,例如刪除所有還在 Queue 中的郵件。

以下是一些常用的指令:

# 列出目前在 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 是如何管理 Mail Queue 的可以參考 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) 程式控管



原文出處:麥屎浮神: Postfix mail queue command
前一個主題 | 下一個主題 | 頁首 | | |



Powered by XOOPS 2.0 © 2001-2008 The XOOPS Project|