關於 PHP, Linux, Open Source 及個人生活記載的網誌。
RSS icon
  • 刪除 Qmail queue 內的郵件

    Posted on January 22nd, 2007 Sam Tang No comments

    在 sendmail 要刪除在 queue 內的郵件很簡單,只需直接在 /var/spool/mqueue 下面刪除就好,但在 Qmail 就較麻煩,執行以下指令會刪除 queue 內所有郵件:

    qmailctl stop
    find /var/qmail/queue/mess -type f -exec rm {} \;
    find /var/qmail/queue/info -type f -exec rm {} \;
    find /var/qmail/queue/local -type f -exec rm {} \;
    find /var/qmail/queue/intd -type f -exec rm {} \;
    find /var/qmail/queue/todo -type f -exec rm {} \;
    find /var/qmail/queue/remote -type f -exec rm {} \;
    qmailctl start

    你可以將以上指令放到一個 shell script 內方便執行。如果想更改郵件留在 queue 內的時間,可以修改 /var/qmail/control/queuelifetime 檔案內的數值,裡面的數值是代表郵件留在 queue 內的秒數,預設值為 86400 秒,即一天。而如果想刪除乎合特定規則的隊列郵件,可以安裝一些現成的工具,以下是其中兩個不錯的選擇:

    Qmail-Remove: 可以刪除有指定字串規則的郵件,在預設的情況下不會直接刪除,而將郵件移到 $qmail-queue/yanked/,可以檢視個別郵件及手動還原。

    qmHandle: 可以實現 qmail-qread 及 qmail-qstat 的功能,能檢視 qmail queue 的內容,及輸出統計資料,輸出的格式更加容易觀看,而且可以刪除一個或多個郵件。


    Leave a reply

    *
    To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
    Click to hear an audio file of the anti-spam word