cancel
Showing results for 
Search instead for 
Did you mean: 

Howto empty a mailq

Arjen Verhulst
Occasional Advisor

Howto empty a mailq

Help !!

After I have send a mail with sendmail I want empty the mailq. I now there is a command to empty the mailq but i forgot it.

I use the folowing command to create the mail:

echo "hello" |mailx -s "test" adress@domain.nl
and I use mailq to whatch in the queue.

Is there anyone how nows to empty the mailq?


Thanks.

Arjen
11 REPLIES
Mark Grant
Honored Contributor

Re: Howto empty a mailq

I think you only need to delete the files in /var/spool/mqueue
Never preceed any demonstration with anything more predictive than "watch this"
Arjen Verhulst
Occasional Advisor

Re: Howto empty a mailq

Thanks for the fast reply...

But I now that it is possible to delete the files in /var/spool/mqueue to empty the queue.

So far I can remember there is a line command to delete a single message of the mailq by using the mail id from that message.

Arjen.
Graham Cameron_1
Honored Contributor

Re: Howto empty a mailq

When you say you want to empty the mailq, I assume you want all items in it to be sent out.

If so, "sendmail -o" should do this, but you really should have sendmail configured to poll and action this queue automatically.
Typically, sendmail is started at boot time with "/usr/sbin/sendmail -bd -q30m"

See man sendmail

And see /var/adm/syslog/mail.log for diagnostics.

-- Graham
Computers make it easier to do a lot of things, but most of the things they make it easier to do don't need to be done.
Arjen Verhulst
Occasional Advisor

Re: Howto empty a mailq

What I mean is as follow, I want to delete a mail before it is send out of the mailq.

Arjen
Graham Cameron_1
Honored Contributor

Re: Howto empty a mailq

In that case, you need to do exactly as Mark suggested earlier.

cd /var/spool/mqueue/
rm *
(or rm the specifi one you want)

-- Graham
Computers make it easier to do a lot of things, but most of the things they make it easier to do don't need to be done.
Arjen Verhulst
Occasional Advisor

Re: Howto empty a mailq

isn't it possible to delete a mail job with a line command ( like an at job "at -r " )

Arjen
Mark Greene_1
Honored Contributor

Re: Howto empty a mailq

To force flush the mailq, run this:

sendmail -v -d8.20 -q

mark
the future will be a lot like now, only later
Elmar P. Kolkman
Honored Contributor

Re: Howto empty a mailq

Use mailq to get the mail-id
Then go to /var/spool/mqueue and delete all files with the specified mail-id on the end:
rm *

(The mail-id is the first column of output from mailq.)
Every problem has at least one solution. Only some solutions are harder to find.
Steven E. Protter
Exalted Contributor

Re: Howto empty a mailq

The first best way to empty the mail queue (mailq shows it) is to run sendmail -q as root.

This should clear it off if there is a connection issue.

If that does not work and it REALLY needs to be cleared rm -f /var/spool/mqueue/*

The -f supresses warning messages. Once its gone, its gone. No bringing it back to life.

Understand that sometimes inbound mail being boucned by a spam filter will create mqueue entries.

To trouble test:

sendmail -v -d8.99 -d38.99 someone@someaddress.com
Type some text

.


This might help you figure out why the mail is hanging up.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Arjen Verhulst
Occasional Advisor

Re: Howto empty a mailq

Thanks for all these reply's so far.

I haven't not get the right anwser yet,but can try to make a script that empty the files with the right mail-id in /var/spool/mqueue

Arjen
Elmar P. Kolkman
Honored Contributor

Re: Howto empty a mailq

I'm afraid the command you're looking for is mailrm. It's a mail I've seen in the past, but isn't available on HP-UX.
Every problem has at least one solution. Only some solutions are harder to find.