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.

Delete Mail Queue for Specific address?

Discussion in 'E-mail Discussions' started by Brad, Nov 14, 2002.

  1. Brad

    Brad Well-Known Member

    Joined:
    Aug 16, 2001
    Messages:
    231
    Likes Received:
    0
    Trophy Points:
    16
    We have script that was exploited for one of our accounts and the mail queue has thousands of emails in it.

    How can I delete all the email in the queue only for that one specific -auth_sender account without dleting everyone elses email?

    I don't want to use the delete all unless I have too..
     
  2. Brad

    Brad Well-Known Member

    Joined:
    Aug 16, 2001
    Messages:
    231
    Likes Received:
    0
    Trophy Points:
    16
    Ok, since I had quite a few private messages by folks with the same problem wanting to know if I found the solution, here is what worked for me..


    Assuming you know a string of characters that is present in each of the emails, but only in those mails, then you can delete them with this line:

    grep -l STRING /var/spool/exim/input/* | xargs rm -rf

    (replace STRING with the characters in the mails that you want to delete)

    Example:
    grep -l account@yourdomain.com /var/spool/exim/input/* | xargs rm -rf

    [b:fb286217ab]Note that this will automatically delete files without prompting you, so be sure the line is exactly correct before running it! [/b:fb286217ab]



    [quote:fb286217ab][i:fb286217ab]Originally posted by Brad[/i:fb286217ab]

    We have script that was exploited for one of our accounts and the mail queue has thousands of emails in it.

    How can I delete all the email in the queue only for that one specific -auth_sender account without dleting everyone elses email?

    I don't want to use the delete all unless I have too..
    [/quote:fb286217ab]
     
  3. SageBrian

    SageBrian Well-Known Member

    Joined:
    Jun 1, 2002
    Messages:
    414
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    NY/CT (US)
    cPanel Access Level:
    Root Administrator
    This is probably something that should be 'sticky'.

    A great tip.
     
  4. kualo

    kualo Member
    PartnerNOC

    Joined:
    Jun 2, 2002
    Messages:
    20
    Likes Received:
    2
    Trophy Points:
    3
    problem...


    we're getting this wrror message:

    bash: /bin/grep: Argument list too long

    Any advice?

    cPanel.net Support Ticket Number:
     
  5. CoolMike

    CoolMike Well-Known Member

    Joined:
    Sep 6, 2001
    Messages:
    307
    Likes Received:
    0
    Trophy Points:
    16
    I have exactly the same problem, I guess there are to many files in this directory. But how can we run this command?

    Thanks
    Michael

    cPanel.net Support Ticket Number:
     
  6. trakwebster

    trakwebster Well-Known Member

    Joined:
    Jan 29, 2003
    Messages:
    145
    Likes Received:
    0
    Trophy Points:
    16
    I have an Ignorant Question ...

    How does one learn that there are thousands of emails in a mail queue?

    For that matter, if I wanted to know how many emails might be lined up for user 'bignose', how would I got about it? (Other than being user bignose and downloading my emails using an email client, that is.)

    I'd be grateful to learn how this is done.
     
    #6 trakwebster, Aug 24, 2003
    Last edited: Aug 24, 2003
  7. Juanra

    Juanra Well-Known Member

    Joined:
    Sep 22, 2001
    Messages:
    777
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Spain
  8. ciphervendor

    ciphervendor Well-Known Member

    Joined:
    Aug 26, 2002
    Messages:
    1,052
    Likes Received:
    0
    Trophy Points:
    36
    Code:
    #!/bin/sh
    
    cd /var/spool/exim/input/
    
    for file in *
    do
    grep -l USER@DOMAIN.COM $file | xargs rm -f 
    
    done
    
    exit
     
  9. trakwebster

    trakwebster Well-Known Member

    Joined:
    Jan 29, 2003
    Messages:
    145
    Likes Received:
    0
    Trophy Points:
    16
    Hi, Juanra,

    Thanks for the info and the link. Somehow it had never quite dawned upon me that exim would have a website, though after you point it out, it's 'of course!'. Their documentation is nicely laid out, so I am doubly grateful for your assistance. Thanks twice!
     
  10. Shneur

    Shneur Member

    Joined:
    Aug 7, 2003
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    Hey thanks for that script, I had 2 questions:

    1. I'm a very newbie to SSH, how does one "create" and execute a "script"? (do I need to create a file, upload it somewhere and execute it? pleae give me details on a step by step how to get that script running)

    2. is there any way I can put a filter in antivirus.exim that will purge all double or more emails (with same exact size) -which are 99% spam-?

    cPanel.net Support Ticket Number:
     
  11. efeito

    efeito Well-Known Member
    PartnerNOC

    Joined:
    Jul 24, 2003
    Messages:
    141
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    .pt
    another try

    I'm trying to eliminate all the emails on queue that have a *.pif file i look at your code, and i do this modification, but the emails still there:

    #!/bin/sh

    cd /var/spool/exim/input/

    for file in *
    do
    grep -l *.pif $file | xargs rm -f

    done

    exit

    -------------
    What's wrong? Can anyone help me please? Thanks!

    cPanel.net Support Ticket Number:
     
  12. ciphervendor

    ciphervendor Well-Known Member

    Joined:
    Aug 26, 2002
    Messages:
    1,052
    Likes Received:
    0
    Trophy Points:
    36
    Re: another try

    By default cPanel bounces emails with attachements that end in pif; so you won't have any in your queue.

    cPanel.net Support Ticket Number:
     
  13. efeito

    efeito Well-Known Member
    PartnerNOC

    Joined:
    Jul 24, 2003
    Messages:
    141
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    .pt
    yes, i have

    I have 115 emails with *.pif attachments in queue.. they are there for more than 40 h some of them... that seems to me that the senders of that emails doesnt exist, so cpanel can return the messages back.

    Sorry if this is a lame answer, but i'm a newbie in this issues. Just trying to learn.

    cPanel.net Support Ticket Number:
     
  14. efeito

    efeito Well-Known Member
    PartnerNOC

    Joined:
    Jul 24, 2003
    Messages:
    141
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    .pt
    Eliminate some emails

    On my mail queue i have a lot of emails for more than 40 hours with this:
    ---------------------
    This message was created automatically by mail delivery software.

    A message that you sent could not be delivered to one or more of its
    recipients. This is a permanent error. The following address(es) failed:

    xxxxx@domain.com
    This message has been rejected because it has
    a potentially executable attachment "your_document.pif"
    This form of attachment has been used by
    recent viruses or other malware.
    If you meant to send this file then please
    package it up as a zip file and resend it.
    -------------------

    I have exim 4.20. Can you please help me, with the script for delete all emails with that "your_document.pif" ?

    Thanks to all!

    cPanel.net Support Ticket Number:
     
  15. shopcentar

    shopcentar Well-Known Member
    PartnerNOC

    Joined:
    Jul 10, 2004
    Messages:
    55
    Likes Received:
    1
    Trophy Points:
    8
    delete specific mail in queue (script)

    Hello,

    here is one of my script for remove 1000 mails for specific user.

    Code:
    #!/bin/sh
    a=0
    cd /var/spool/exim/input/
    
    for file in *
     do
       a=$(($a+1))
       dir_path[$a]=$file
       echo $file " " $a " " ${dir_path[$a]}
     done
    
    LIMIT=$a
    a=0
    while [ $a -le "$LIMIT" ]
    do
    a=$(($a+1))
    cd /var/spool/exim/input/${dir_path[$a]}
    echo "======="${dir_path[$a]}"======"
    for file in *
     do
       #echo $file
       grep -l [B]USER@DOMAIN.COM[/B] $file | xargs rm -f
     done
    echo "=======END dir======"
    done
    
    echo "=======END======"
    exit
    by, SC
     
  16. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    Or do it on one line ;)

    grep -lir user\@domain\.com /var/spool/exim/input/* | xargs rm -fv
     
  17. shopcentar

    shopcentar Well-Known Member
    PartnerNOC

    Joined:
    Jul 10, 2004
    Messages:
    55
    Likes Received:
    1
    Trophy Points:
    8
    you RULE man!
    great line!

    my script is like spectrum vs XEON-your one line :)

    Thanks for tip.

    by, SC
     
  18. brianoz

    brianoz Well-Known Member

    Joined:
    Mar 13, 2004
    Messages:
    1,146
    Likes Received:
    6
    Trophy Points:
    38
    Location:
    Melbourne, Australia
    cPanel Access Level:
    Root Administrator
    Great idea, but won't work with a really large input directory.

    try either:

    cd /var/spool/exim/input; grep -lir user\@domain\.com * | xargs rm -fv

    (that was a minor modification which will work for more files than the original, but will still fail for really really large input directories)

    ... or the following, which will work for any number of files in the input directory:

    grep -lir user\@domain\.com /var/spool/exim/input | xargs rm -fv
     
    #18 brianoz, Feb 2, 2005
    Last edited: Feb 2, 2005
  19. dinfiesta

    dinfiesta Well-Known Member

    Joined:
    May 2, 2005
    Messages:
    58
    Likes Received:
    0
    Trophy Points:
    6
    How do i delete messages that are in queue for more than 7 days?

    Thanks.
     
  20. WillBlack

    WillBlack Member

    Joined:
    Oct 24, 2006
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    Mail

    Hi there guys, great input.
    I have accounts that have email, but these are not user@domain.com accounts they are the actuall username accounts that get created by WHM.
    Example:
    I create a site blackbuzz.com and the username that gets created called blackbuz (doesnt really have an inbox, other than something that gets created by default) and that blackbuz is filling up with (catchall, I assume) spam.

    I have tried the previous commands in this thread with no luck, there are still 4200 emails in the queue.

    How do I delete the queue for this default (non) email user?

    Thanks
    W
     
Loading...

Share This Page