Sunday, 4 September 2011

Ubuntu - Clean Sendmail Queue

If you need to clear sendmail queue the following is some very usefull commands for doing the job

To check how many pending mail you have use:

  • mailq -v

Manually removed pending mails:
  • rm /var/spool/mail/*.*
  • rm /var/spool/mqueue/*.*

Delete pending mails using sendmail command
  • sendmail -v -q

You can delete certain domain or user or recipient mail using the following command
  • sendmail -qS -v domainname.com it will delete all mail from *@domainname.com

Delete mail from recipient
  • sendmail -qR -v gmail.com

You can also use find command to removed queues
  • find /var/spool/mqueue -type f -exec grep "Deferred: Connection refused" {} \; -exec rm -rf {} \;

Hope this help!
Source:  http://www.review-ninja.com/2009/11/clean-sendmail-queue-ubuntu-linux-howto.html

No comments:

Post a Comment