How to Flush Mail Queue in Linux
# mailq
# sendmail -bp
# sendmail -bp
Sample Outputs
/var/spool/mqueue (3 requests)
-----Q-ID----- --Size-- -----Q-Time----- ------------Sender/Recipient-----------
v3G31Qbu031236 147 Sun Apr 16 08:31 <root@ebis.expolanka.com>
(host map: lookup (expolanka.com): deferred)
<dbateam@expolanka.com>
# cd /var/spool/mqueue/
# ls
# rm *
# /etc/init.d/sendmail restart
----------------------------------------------------------------------------------------------------------------------
vi /etc/mail/mailertable
expolanka.com esmtp:[10.2.20.160]
restart sendmail
----------------------------------------------------------------------------------------------------------------------
qtool.pl Tool
Sendmail mail server does not provide any command to remove messages from the mail queue. The above will delete all messages from the mail queue. You can use qtool.pl scriptlocated in sendmail source code contrib directory as follows:
Sample outputs:
# mailq
Sample outputs:
/var/spool/mqueue (1 request) -----Q-ID----- --Size-- -----Q-Time----- ------------Sender/Recipient----------- p61J75u5037681 893 Fri Jul 1 14:078BITMIME (Deferred: Connection timed out with example.com.) Total requests: 1
Note down Q-ID p61J75u5037681 and run qtool.pl as follows:
Where,
# ./qtool.pl -C /etc/mail/sendmail.cf -d /var/spool/mqueue/p61J75u5037681
Where,
- -C /etc/mail/sendmail.cf – Specify sendmail config file.
- -d /var/spool/mqueue/p61J75u5037681 – Delete the messages specified by source. In this case by Q-ID.
- qtool.pl from Sendmail source code contrib directory.
- Deleting mail from the mail queue using various Perl script wrapper.
To delete all messages queued for the example.com domain. First, you need to set QIDS either using the mailq command or manually as follows:
OR
Use the following bash for loop to delete all messages for example.com:
No comments:
Post a Comment