Plesk versions 9 and above are bundled with the following Mail Transfer Agents (MTA). One of them can be used as the MTA of Plesk server at a time.
- Qmail
- Postfix
In order to find which MTA is being used by Plesk, you can go to the following option in Plesk.
Plesk >> Home >> Services management.
Or you can use the ‘mailmang’ utility of Plesk to find the current MTA from command line.
#plesk sbin mailmng-server –features | grep SMTP_Server
The result will be shown like the following.
For Postfix:
$features[‘SMTP_Server’] = “Postfix”;
For Qmail:
$features[‘SMTP_Server’] = “QMail”;
$features[‘SMTP_Server_package’] = “psa-qmail”;
User’s mailboxes are saved under /var/qmail/mailnames.
For e.g. /var/qmail/mailnames/example.com/<username>
Now we will take a look into basic commands to manage Qmail queue on a Linux Plesk server.
1. Find the number of email messages in the queue.
#/var/qmail/bin/qmail-qstat
Example results:
messages in queue: 78
messages in queue but not yet preprocessed: 0
2.Find details of emails in the mail queue.
#/var/qmail/bin/qmail-qread
The result will show the message id (for e.g. #3453345) and other details. The exact email with header will be stored under the following folders under ‘/var/qmail/queue’.
bounce
info
mess
remote
local
todo
intd
3.Read a particular email in the mail queue.
#find /var/qmail/queue -name <message-id>| xargs cat | less
E.g. find /var/qmail/queue -name 3453345| xargs cat | less
Or find where the email is stored under /var/qmail/queue, and read it.
#find /var/qmail/queue -iname 3453345
/var/qmail/queue/remote/18/3453345
/var/qmail/queue/mess/18/3453345
/var/qmail/queue/info/18/3453345
#vi /var/qmail/queue/mess/18/3453345
4.You can delete all emails from the queue using the following commands.
Since the messages are being stored in different folders under /var/qmail/queue, we need to remove them all.
IMPORTANT: Stop qmail service before performing following actions.
#service qmail 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 {} \;
service qmail start
These are basic commands to manage email queue with Qmail. If you want to remove messages which contains a particular string or IP address, you can install and use additional tools like qmHandle or Qmail-Remove.
https://www.linuxmagic.com/opensource/qmail/qmail-remove/
https://sourceforge.net/projects/qmhandle/
1. qmHandle
Download qmHandle from https://sourceforge.net/projects/qmhandle/ and extract it.
#wget https://downloads.sourceforge.net/project/qmhandle/qmhandle-1.3/qmhandle-1.3.2/qmhandle-1.3.2.tar.gz
#tar -xzvf qmhandle-x.y.z.tar.gz
#cd qmhandle-x.y.z
#mv qmHandle /usr/local/sbin/
#chmod +x /usr/local/sbin/qmHandle
#qmHandle -h
Example:
List messages in queue.
#qmHandle -l
Remove messages that contains ‘example.com’ as subject.
#qmHandle -l -S example.com
2. Qmail-Remove
Download and install package from https://www.linuxmagic.com/opensource/qmail/qmail-remove/
#wget https://www.linuxmagic.com/opensource/qmail/qmail-remove/qmail-remove-0.95.tar.gz
#tar -zxvf qmail-remove-0.95.tar.gz
#cd qmail-remove-0.95
#make && make install
#mkdir /var/qmail/queue/yanked(This tool will remove emails from the queue and yank them into this directory).
#qmail-remove -h
Example:
Remove mails from queue which contains the pattern ‘example.com’.
#qmail-remove -r -p example.com
” margin_top=”50px” margin_bottom=”” animation_type=”slide” animation_direction=”left” animation_speed=”0.3″ class=”” id=””]
Leave A Comment
You must be logged in to post a comment.