Board logo

subject: How to flush sendmail mail queue under linux directly or by requirements [print this page]


How to flush sendmail mail queue under linux directly or by requirements

Sometimes mail server may be DNS or spam mail problem, lot of emails pening in the mail queue,So, You can use the following methods to flush/push pending emails out:

1) Automatically method:

- With root pemission, typing the command which flush all the pending mails out.

sendmail -v -q

- Then use the following command to check the mailq status, it should be all mail queue deleted.

mailq

2) Manually method:

- stop the sendmail service

/etc/init.d/sendmail stop

- delete /var/spool/mqueue/*.* & /var/spool/clientmqueue/*.* files

(Normally there will be files with df* and qf* as a prefix for each mail waiting to be sent, you can delete the ones you don't want sent or delete all)

- restart the sendmail service

/etc/init.d/sendmail start

- Then use the following command to check the mailq status, it should be all mail queue deleted.

mailq

3) If you want to delete perticular domain or user or recipient or header content

- In order to delete all mail [from] *@techutter.com:

sendmail -qS -v techutter.com

- In order to delete all mail from [recepient] of techutter.com:

sendmail -qR -v techutter.com

- You can also use find command to removed queues by grep result(time consuming),

extra option you can use(e.g : -amin +180 -print0), man find for more information:

Do you want extra technical tips? If Yes! Then,Click Here to visit my website "Techutter " now ^_^ ...welcome la

find /var/spool/mqueue -type f -exec grep "Deferred: Connection refused" {} ; -exec rm -rf {} ;




welcome to loan (http://www.yloan.com/) Powered by Discuz! 5.5.0