Koozali.org: home of the SME Server

Obsolete Releases => SME Server 7.x => Topic started by: mdo on April 22, 2010, 06:40:04 AM

Title: How to remove emails out of qmail queue?
Post by: mdo on April 22, 2010, 06:40:04 AM
I would like to ask for some advice on this one:

A user rang to report a slow Internet connection and our investigation showed that they had accidentally sent out an email with 7MB attachment to a mailing list of about 300 recipients. The server was fighting against the limit in the broadband connection's upload speed.

What is the best way to remove many emails that are still to be delivered in qmail's outgoing queue? There is a contrib available which install 'qmHandle' to allow deletes from the commandline but to do a
qmHandle -d1234 -d2345 -d3456  .... etc.
takes very long because this tool tries to terminate qmail each time ("Calling system script to terminate qmail...").

Is there a better/faster way to remove many emails in one go?

Thanks for any help.
Michael     
Title: Re: How to remove emails out of qmail queue?
Post by: JonB on April 22, 2010, 12:29:12 PM
Use qmHandle -Stext where text is some text from the subject assuming the 300 emails have the the same subject. e.g to remove emails with 'failure notice' in the qmail queues use

qmHandle -Sfailure

this will delete all emails with 'failure' in the subject

qmhandle will terminate qmail once, delete the emails and restart qmail again (hopefully)
Title: Re: How to remove emails out of qmail queue?
Post by: byte on April 22, 2010, 12:48:15 PM
Another way I've done it in the past is first of all and most importantly is to stop qmail before doing anything else, next check the qmail stats (is there our 300 emails)

/var/qmail/bin/qmail-qstat

Then only if you know the 300 emails are the ones you want to remove you can then do the following:

find /var/qmail/queue/local -type f -exec rm {} \;
find /var/qmail/queue/remote -type f -exec rm {} \;

Very crude way but worked for me in the past, then don't forget to start qmail after you're finished.

I think I remember a very long time ago that Charlie mentioned qmHandle doesn't restart qmail properly so its best to stop qmail and start qmail once you're ready.
Title: Re: How to remove emails out of qmail queue?
Post by: CharlieBrady on April 22, 2010, 03:05:42 PM
Then only if you know the 300 emails are the ones you want to remove you can then do the following:

find /var/qmail/queue/local -type f -exec rm {} \;
find /var/qmail/queue/remote -type f -exec rm {} \;

Do not do this unless you have already stopped qmail *and* qpsmtpd and you are absolutely sure that the only messages in the queue are ones which you wish to delete. Messages can still be added to the queue while qmail is not running, which is why it is necessary to stop qpsmtpd.

The earlier advice to select by text is safer, but be as specific as possible. 'failure' is not sufficiently specific.

My personal advice would be to consider telling the customer to just be patient, and to think twice next time.
Title: Re: How to remove emails out of qmail queue?
Post by: JonB on April 22, 2010, 03:42:22 PM
It was a quick example

qmhandle -S'failure notice'

would be more specific

I usually run

qmHandle -R > /tmp/remotequeue.txt

first to check what messages are in the queue and which emails based on subject text can be removed.
Title: Re: How to remove emails out of qmail queue?
Post by: mdo on April 22, 2010, 08:17:04 PM
Thank you all for your help with that. JonB's will be my favorite and I should have figured the possibility to delete by subject earlier.

(I think) I understand the dangers and limits e.g. I always generate a list of mails in the queue first and based on this would decide on the specific subject to delete. I also stop/restart qmail manually at the end and usually send a test mail to double check that mail delivery works.

There were a lot of other, valid emails in the queues between the 'bad' ones so byte's way would have been difficult if not impossible for that scenario.

Thanks again, Michael.
Title: Re: How to remove emails out of qmail queue?
Post by: vjohannesen on June 14, 2010, 12:15:27 AM
Hi sorry for jumping on this thread, but have tried to search and this is somehow related.
I have a similar problem with around 30.000 mails in queue.
I am have been trying these suggestions by deleting by subject and by number, but I can not figure out to use qmHandle.

When I for ex. try: "qmHandle -D" the server just hangs with message: "Calling system script to terminate qmail..."
Is there any workaround for this?

-
VJ
Title: Re: How to remove emails out of qmail queue?
Post by: janet on June 14, 2010, 01:34:25 AM
mdo

Quote
A user rang to report a slow Internet connection and our investigation showed that they had accidentally sent out an email with 7MB attachment to a mailing list of about 300 recipients. The server was fighting against the limit in the broadband connection's upload speed.

While it is appropriate to delete emails and to teach users not to send large attachments to mailing lists, it does not solve the issue of bandwidth utilisation.
See
http://wiki.contribs.org/Wondershaper
and there is also a newer contrib rpm in smecontribs repo (smeserver-htbwshaper-1.0-7.el4.sme.noarch.rpm ), so just do
yum install --enablerepo=smecontribs smserver-htpshaper
Configure appropriately for your upload bandwidth and in future even if a user does something inappropriate, your system will still function adequately.

You can also configure the number of concurrent email messages being sent by the system, to reduce the email load on your system at any point in time, search here for details.
Title: Re: How to remove emails out of qmail queue?
Post by: mmccarn on June 14, 2010, 05:30:53 PM
Hi sorry for jumping on this thread, but have tried to search and this is somehow related.
I have a similar problem with around 30.000 mails in queue.
I am have been trying these suggestions by deleting by subject and by number, but I can not figure out to use qmHandle.

When I for ex. try: "qmHandle -D" the server just hangs with message: "Calling system script to terminate qmail..."
Is there any workaround for this?

-
VJ

You should be able to stop qmail manually using sv stop qmail then run the desired "qmHandle" command.

Here are some possibly relevant links:
http://forums.contribs.org/index.php?topic=33791.0
http://bugs.contribs.org/show_bug.cgi?id=2020
Title: Re: How to remove emails out of qmail queue?
Post by: CharlieBrady on June 14, 2010, 05:40:31 PM
I have a similar problem with around 30.000 mails in queue.

Your first steps need to be to stop qmail and qpsmtpd, and then discover why you have 30,000 mails in the queue. Don't try to remove items from the queue until you discover how and why they are there.