Clearing out your sendmail queue
This article tells you how to clear your outgoing mail queue.
I had a message that
wasn’t going away. And I didn’t want to wait for it to time out after the standard 5
days of trying. Here’s the message that was filling up my logs:
Mar 16 14:38:04 ns sendmail[20351]: VAA03402: to=akela@akela.ti.cz, delay=4+17:24:11, xdelay=00:01:16, mailer=esmtp Mar 16 15:08:04 ns sendmail[20404]: VAA03402: to=akela@akela.ti.cz, delay=4+17:54:11, xdelay=00:01:16, mailer=esmtp Mar 16 15:38:04 ns sendmail[20450]: VAA03402: to=akela@akela.ti.cz, delay=4+18:24:11, xdelay=00:01:15, mailer=esmtp
Every 30 minutes. I was getting sick of it! <grin> So here’s
how I cleared it out:
# sendmail -bp
That will print a list of the mail queue. Then you do manually remove the ones
you want:
# cd /var/spool/mqueue # rm <insert your file name here>
mailq
There’s almost always more than one way to do something. As Sue Blake point out
to me with this command, which I had not heard of. From the man page:
Mailq prints a summary of the mail messages queued for future delivery.
And as Sue pointed out, mailq is much easier to remember.
Here is a comparison of the output of the two commands. For privacy reasons, I
have changed the actual email address.
$ mailq Mail Queue (1 request) --Q-ID-- --Size-- -----Q-Time----- ------------Sender/Recipient------- WAB69608 747 Sun Jun 20 22:55 owner-freebsddiary-announce (host map: lookup (somedomain.net): deferred) someone@somedomain.net $ sendmail -bp Mail Queue (1 request) --Q-ID-- --Size-- -----Q-Time----- ------------Sender/Recipient------- WAB69608 747 Sun Jun 20 22:55 owner-freebsddiary-announce (host map: lookup (somedomain.net): deferred) someone@somedomain.net
This is good info. Here’s another twist on this to make even easier.
Using a good FTP client, such as SecureFX from VanDyke Software, connect to your server and CD to the directory your mail queue is in (it’s /var/spool/mqueue on my server) then, in the file window, click the column bar for date sorting the list in date order. Then select all files that you think are too old and delete them. Follow that with a cron tab to execute a "sendmail -q -v" every morning about 2 am and your problems should go away.