「広告」

Qmail、キューに溜まったメールを削除する方法

「広告」
記事内に広告が含まれています。
「広告」

Qmailを運用していて、何らかの原因で、キューに溜まったメールを削除する方法を・・・
昔から使われているツールです。

すべて、Qmailを停止してから行います。

「広告」

宛先を指定して削除

キューに溜まったメール、宛先を指定する場合。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# wget http://www.kawa.net/works/qmail/src/queue-fast.20050210.tar.gz
# tar zxvf queue-fast.20050210.tar.gz
# wget http://www.kawa.net/works/qmail/src/queue-fast.20050210.tar.gz # tar zxvf queue-fast.20050210.tar.gz
# wget http://www.kawa.net/works/qmail/src/queue-fast.20050210.tar.gz
# tar zxvf queue-fast.20050210.tar.gz

↑ツールをダウンロードします。

queue-fast.pl
が実行ファイルです。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# perl queue-fast.pl 宛先メールアドレス
# perl queue-fast.pl 宛先メールアドレス
# perl queue-fast.pl 宛先メールアドレス

で、チェック。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# perl queue-fast.pl 宛先メールアドレス
# address: 宛先メールアドレス
# 0 messages found in /var/qmail/queue/mess/0 (1/23)
# 1 messages found in /var/qmail/queue/mess/1 (2/23)
1/1581021 R - => 宛先メールアドレス
# 0 messages found in /var/qmail/queue/mess/2 (3/23)
# 0 messages found in /var/qmail/queue/mess/3 (4/23)
# 0 messages found in /var/qmail/queue/mess/4 (5/23)
# perl queue-fast.pl 宛先メールアドレス # address: 宛先メールアドレス # 0 messages found in /var/qmail/queue/mess/0 (1/23) # 1 messages found in /var/qmail/queue/mess/1 (2/23) 1/1581021 R - => 宛先メールアドレス # 0 messages found in /var/qmail/queue/mess/2 (3/23) # 0 messages found in /var/qmail/queue/mess/3 (4/23) # 0 messages found in /var/qmail/queue/mess/4 (5/23)
# perl queue-fast.pl 宛先メールアドレス
# address: 宛先メールアドレス
# 0 messages found in /var/qmail/queue/mess/0 (1/23)
# 1 messages found in /var/qmail/queue/mess/1 (2/23)
1/1581021 R - => 宛先メールアドレス
# 0 messages found in /var/qmail/queue/mess/2 (3/23)
# 0 messages found in /var/qmail/queue/mess/3 (4/23)
# 0 messages found in /var/qmail/queue/mess/4 (5/23)

↑チェックの実行例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# perl queue-fast.pl -d 宛先メールアドレス
# perl queue-fast.pl -d 宛先メールアドレス
# perl queue-fast.pl -d 宛先メールアドレス

↑で、実際の削除となります。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# perl queue-fast.pl -d 宛先メールアドレス
# address: 宛先メールアドレス
# delete mode enabled.
# 0 messages found in /var/qmail/queue/mess/0 (1/23)
# 1 messages found in /var/qmail/queue/mess/1 (2/23)
1/1581021 R - => 宛先メールアドレス
deleteing: /var/qmail/queue/mess/1/1581021 /var/qmail/queue/info/1/1581021 /var/qmail/queue/remote/1/1581021
# 0 messages found in /var/qmail/queue/mess/2 (3/23)
# perl queue-fast.pl -d 宛先メールアドレス # address: 宛先メールアドレス # delete mode enabled. # 0 messages found in /var/qmail/queue/mess/0 (1/23) # 1 messages found in /var/qmail/queue/mess/1 (2/23) 1/1581021 R - => 宛先メールアドレス deleteing: /var/qmail/queue/mess/1/1581021 /var/qmail/queue/info/1/1581021 /var/qmail/queue/remote/1/1581021 # 0 messages found in /var/qmail/queue/mess/2 (3/23)
# perl queue-fast.pl -d 宛先メールアドレス
# address: 宛先メールアドレス
# delete mode enabled.
# 0 messages found in /var/qmail/queue/mess/0 (1/23)
# 1 messages found in /var/qmail/queue/mess/1 (2/23)
1/1581021 R - => 宛先メールアドレス
deleteing: /var/qmail/queue/mess/1/1581021 /var/qmail/queue/info/1/1581021 /var/qmail/queue/remote/1/1581021
# 0 messages found in /var/qmail/queue/mess/2 (3/23)

↑削除の実行例

「広告」

差出人を指定して削除

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# wget https://sourceforge.net/projects/qmhandle/files/latest/download --no-check-certificate -O qmhandle-1.3.2.tar.gz
# tar xzvf qmhandle-1.3.2.tar.gz
# cp qmhandle-1.3.2/qmHandle .
# wget https://sourceforge.net/projects/qmhandle/files/latest/download --no-check-certificate -O qmhandle-1.3.2.tar.gz # tar xzvf qmhandle-1.3.2.tar.gz # cp qmhandle-1.3.2/qmHandle .
# wget https://sourceforge.net/projects/qmhandle/files/latest/download --no-check-certificate -O qmhandle-1.3.2.tar.gz
# tar xzvf qmhandle-1.3.2.tar.gz
# cp qmhandle-1.3.2/qmHandle .

↑ qmHandle をダウンロードして、queue-fast.pl と同じディレクトリにコピーします。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# vi qmail_from_del.sh
-----------------------------------------------------------------------
#!/bin/sh
if [ $# -ne 1 ]; then
exit 1
fi
QID=`perl queue-fast.pl | grep $1 | cut -d" " -f1 | cut -d"/" -f2`
for var in ${QID}
do
if [ ! -z "$var" ] ; then
perl qmHandle -d${var}
fi
done
-----------------------------------------------------------------------
# vi qmail_from_del.sh ----------------------------------------------------------------------- #!/bin/sh if [ $# -ne 1 ]; then exit 1 fi QID=`perl queue-fast.pl | grep $1 | cut -d" " -f1 | cut -d"/" -f2` for var in ${QID} do if [ ! -z "$var" ] ; then perl qmHandle -d${var} fi done -----------------------------------------------------------------------
# vi qmail_from_del.sh
-----------------------------------------------------------------------
#!/bin/sh

if [ $# -ne 1 ]; then
 exit 1
fi

QID=`perl queue-fast.pl | grep $1 | cut -d" " -f1 | cut -d"/" -f2`
for var in ${QID}
do
    if [ ! -z "$var" ] ; then
    perl qmHandle -d${var}
    fi
done
-----------------------------------------------------------------------
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# chmod 755 qmail_from_del.sh
# chmod 755 qmail_from_del.sh
# chmod 755 qmail_from_del.sh

↑「qmail_from_del.sh」という実行ファイルを作ります。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# ./qmail_from_del.sh (差出人メールアドレス)
# ./qmail_from_del.sh (差出人メールアドレス)
# ./qmail_from_del.sh (差出人メールアドレス)

↑ 上記で削除ができます。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# ./qmail_from_del.sh (差出人メールアドレス)
# 0 messages found in /var/qmail/queue/mess/0 (1/23)
# 1 messages found in /var/qmail/queue/mess/1 (2/23)
# 0 messages found in /var/qmail/queue/mess/2 (3/23)
# 0 messages found in /var/qmail/queue/mess/3 (4/23)
# 0 messages found in /var/qmail/queue/mess/4 (5/23)
# 0 messages found in /var/qmail/queue/mess/5 (6/23)
# 0 messages found in /var/qmail/queue/mess/6 (7/23)
# 0 messages found in /var/qmail/queue/mess/7 (8/23)
# 0 messages found in /var/qmail/queue/mess/8 (9/23)
# 0 messages found in /var/qmail/queue/mess/9 (10/23)
# 0 messages found in /var/qmail/queue/mess/10 (11/23)
# 0 messages found in /var/qmail/queue/mess/11 (12/23)
# 0 messages found in /var/qmail/queue/mess/12 (13/23)
# 0 messages found in /var/qmail/queue/mess/13 (14/23)
# 0 messages found in /var/qmail/queue/mess/14 (15/23)
# 0 messages found in /var/qmail/queue/mess/15 (16/23)
# 0 messages found in /var/qmail/queue/mess/16 (17/23)
# 1 messages found in /var/qmail/queue/mess/17 (18/23)
# 0 messages found in /var/qmail/queue/mess/18 (19/23)
# 0 messages found in /var/qmail/queue/mess/19 (20/23)
# 0 messages found in /var/qmail/queue/mess/20 (21/23)
# 0 messages found in /var/qmail/queue/mess/21 (22/23)
# 0 messages found in /var/qmail/queue/mess/22 (23/23)
Qmail isn't running... no need to stop it.
Deleting message 1581021...
Deleted 1 messages from queue
Qmail wasn't running when qmHandle was started, so it won't be restarted.
# ./qmail_from_del.sh (差出人メールアドレス) # 0 messages found in /var/qmail/queue/mess/0 (1/23) # 1 messages found in /var/qmail/queue/mess/1 (2/23) # 0 messages found in /var/qmail/queue/mess/2 (3/23) # 0 messages found in /var/qmail/queue/mess/3 (4/23) # 0 messages found in /var/qmail/queue/mess/4 (5/23) # 0 messages found in /var/qmail/queue/mess/5 (6/23) # 0 messages found in /var/qmail/queue/mess/6 (7/23) # 0 messages found in /var/qmail/queue/mess/7 (8/23) # 0 messages found in /var/qmail/queue/mess/8 (9/23) # 0 messages found in /var/qmail/queue/mess/9 (10/23) # 0 messages found in /var/qmail/queue/mess/10 (11/23) # 0 messages found in /var/qmail/queue/mess/11 (12/23) # 0 messages found in /var/qmail/queue/mess/12 (13/23) # 0 messages found in /var/qmail/queue/mess/13 (14/23) # 0 messages found in /var/qmail/queue/mess/14 (15/23) # 0 messages found in /var/qmail/queue/mess/15 (16/23) # 0 messages found in /var/qmail/queue/mess/16 (17/23) # 1 messages found in /var/qmail/queue/mess/17 (18/23) # 0 messages found in /var/qmail/queue/mess/18 (19/23) # 0 messages found in /var/qmail/queue/mess/19 (20/23) # 0 messages found in /var/qmail/queue/mess/20 (21/23) # 0 messages found in /var/qmail/queue/mess/21 (22/23) # 0 messages found in /var/qmail/queue/mess/22 (23/23) Qmail isn't running... no need to stop it. Deleting message 1581021... Deleted 1 messages from queue Qmail wasn't running when qmHandle was started, so it won't be restarted.
# ./qmail_from_del.sh (差出人メールアドレス)
# 0 messages found in /var/qmail/queue/mess/0 (1/23)
# 1 messages found in /var/qmail/queue/mess/1 (2/23)
# 0 messages found in /var/qmail/queue/mess/2 (3/23)
# 0 messages found in /var/qmail/queue/mess/3 (4/23)
# 0 messages found in /var/qmail/queue/mess/4 (5/23)
# 0 messages found in /var/qmail/queue/mess/5 (6/23)
# 0 messages found in /var/qmail/queue/mess/6 (7/23)
# 0 messages found in /var/qmail/queue/mess/7 (8/23)
# 0 messages found in /var/qmail/queue/mess/8 (9/23)
# 0 messages found in /var/qmail/queue/mess/9 (10/23)
# 0 messages found in /var/qmail/queue/mess/10 (11/23)
# 0 messages found in /var/qmail/queue/mess/11 (12/23)
# 0 messages found in /var/qmail/queue/mess/12 (13/23)
# 0 messages found in /var/qmail/queue/mess/13 (14/23)
# 0 messages found in /var/qmail/queue/mess/14 (15/23)
# 0 messages found in /var/qmail/queue/mess/15 (16/23)
# 0 messages found in /var/qmail/queue/mess/16 (17/23)
# 1 messages found in /var/qmail/queue/mess/17 (18/23)
# 0 messages found in /var/qmail/queue/mess/18 (19/23)
# 0 messages found in /var/qmail/queue/mess/19 (20/23)
# 0 messages found in /var/qmail/queue/mess/20 (21/23)
# 0 messages found in /var/qmail/queue/mess/21 (22/23)
# 0 messages found in /var/qmail/queue/mess/22 (23/23)
Qmail isn't running... no need to stop it.
Deleting message 1581021...
Deleted 1 messages from queue
Qmail wasn't running when qmHandle was started, so it won't be restarted.

↑上記が実行例

「広告」

Qmailのキュー内部の整合性が合わなくなったら・・・

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
warning: trouble opening remote/X/XXXXXXX; will try again later
warning: trouble opening remote/X/XXXXXXX; will try again later
warning: trouble opening remote/X/XXXXXXX; will try again later
warning: trouble opening remote/X/XXXXXXX; will try again later
warning: trouble opening remote/X/XXXXXXX; will try again later warning: trouble opening remote/X/XXXXXXX; will try again later warning: trouble opening remote/X/XXXXXXX; will try again later warning: trouble opening remote/X/XXXXXXX; will try again later
warning: trouble opening remote/X/XXXXXXX; will try again later
warning: trouble opening remote/X/XXXXXXX; will try again later
warning: trouble opening remote/X/XXXXXXX; will try again later
warning: trouble opening remote/X/XXXXXXX; will try again later

↑というエラーが出てきたら・・・

Qmailのキューに関して、整合性が合わなくなってきたという事です。

このエラーは、放置してもいいような気もしますが、
このエラーを解決するツールが出ています。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# wget http://www.netmeridian.com/e-huss/queue-fix.tar.gz
# tar xzvf queue-fix.tar.gz
# cd queue-fix-1.4/
# wget http://www.netmeridian.com/e-huss/queue-fix.tar.gz # tar xzvf queue-fix.tar.gz # cd queue-fix-1.4/
# wget http://www.netmeridian.com/e-huss/queue-fix.tar.gz
# tar xzvf queue-fix.tar.gz 
# cd queue-fix-1.4/
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
vi error.h
extern int errno;
 ↓
#include <errno.h>
# make
vi error.h extern int errno;  ↓ #include <errno.h> # make
vi error.h

extern int errno;
 ↓
#include <errno.h>

# make

↑ error.hの一部を修正します。そして、「make」をして、実行ファイルを作成します。

「queue-fix」
という実行ファイルが作成されたことを確認します。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# ./queue-fix -i /var/qmail/queue
# ./queue-fix -i /var/qmail/queue
# ./queue-fix -i /var/qmail/queue

↑と実行させます。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# ./queue-fix -i /var/qmail/queue
queue-fix finished...
# ./queue-fix -i /var/qmail/queue queue-fix finished...
# ./queue-fix -i /var/qmail/queue
queue-fix finished...

↑ 実行例です。

タイトルとURLをコピーしました