Wednesday, November 11, 2009

Clean Sendmail Queue | Ubuntu Linux Howto

Tech Blog - 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 the "mailq -v" command.

Manually removed pending mails
$ rm /var/spool/mail/*.*
$ rm /var/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!

1 comment:

Anonymous said...

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


this command will delete only header files of deferred mails.how can i delete data file associated with header file?

For suggestion and concerns E-mail