The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

remove specific messages from exim queue

Discussion in 'General Discussion' started by jfall, Mar 13, 2005.

  1. jfall

    jfall Member

    Joined:
    May 8, 2004
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    A user on one of my servers had bad PHP code which caused a mail loop. There are over 20,000 messages sitting in the queue that are from this particular user. How can I remove those specific messages without harming other valid messages in the queue?
     
  2. DigitalN

    DigitalN Well-Known Member

    Joined:
    Sep 23, 2004
    Messages:
    420
    Likes Received:
    1
    Trophy Points:
    18
    You could script something to remove only mail based on your search criteria.

    Here's a quick dirty way that may do what you need though

    # cd /var/spool/exim/input

    # grep -r 'sender@domain.com' * | awk '{print $1}' | cut -d: -f1 | xargs rm -f

    Try without the | xargs rm -f first, to see what will be removed maybe.

    # grep -r 'sender@domain.com' * | awk '{print $1}' | cut -d: -f1

    Use at your own risk. :)
     
  3. jfall

    jfall Member

    Joined:
    May 8, 2004
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Yeah, I was thinking about that. I thought there may have been a more efficient way (like qmail has qmail-remove). Greping 20,000+ messages isn't something that is very effieicent, however it may get the job done
     
  4. DigitalN

    DigitalN Well-Known Member

    Joined:
    Sep 23, 2004
    Messages:
    420
    Likes Received:
    1
    Trophy Points:
    18
    Indeed, you might want to 'nice' it to avoid high loads while grepping.
     
  5. astopy

    astopy Well-Known Member

    Joined:
    Apr 3, 2003
    Messages:
    165
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    I've been using a script I wrote based on this thread for several months to remove certain mass emails from the queue. I've just discovered a problem with this method that others may like to know about.

    It started when I noticed that it was taking a very long time to grep the few hundred messages in the queue - well over 10 minutes, probably more. So I decided to take a little look inside the directories inside /var/spool/exim/input and instantly noticed there were many, many more files than there should be. After some poking around, I soon discovered the problem: Exim stores the message headers in separate files to the message bodies, and this method of removing messages only removes the headers! I still had the message bodies from month's worth of deleted mail sitting there. I counted the files and there were well over 150,000 of them, that's over 600MB of data. No wonder grep was taking so damn long :)

    I did the following to clean up the mess, without removing the few legitimate messages in the mail queue:
    Code:
    cd /var/spool/exim/input/
    for f in */*-D; do if [ ! -f `echo $f | tr -- -D -H` ]; then rm -f $f; fi; done
    This command is still running and has so far removed about 100MB worth of files. It's not exactly fast, but it's working :)
     
Loading...

Share This Page