Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Delete Mail Queue using SSH?

Discussion in 'E-mail Discussion' started by webdsn, Mar 4, 2018.

  1. webdsn

    webdsn Active Member

    Joined:
    Mar 4, 2018
    Messages:
    29
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    Taiwan
    cPanel Access Level:
    Root Administrator
    I have one account send a lot spam mail
    there are lots mail in Queue

    I want use ssh to delete that without stop exim service
     
  2. sparek-3

    sparek-3 Well-Known Member

    Joined:
    Aug 10, 2002
    Messages:
    1,743
    Likes Received:
    110
    Trophy Points:
    343
    cPanel Access Level:
    Root Administrator
    If you know the envelope-sender of whoever is sending the messages you can list all of those message ids with:

    exiqgrep -if %envelope-sender%

    That will list all message ids that contain %envelope-sender%.

    I would encourage you to review these messages and make sure that you really want to remove them from the mail queue, because piping this list of message ids through exim to remove the messages, will remove the messages. There is no going back after you remove a message from the mail queue, so I really stress extreme caution when removing messages from the mail queue.

    To remove the message ids that match this envelope-sender you would use:

    exiqgrep -if %envelope-sender% | xargs -n1 exim -Mrm

    But I really, really encourage extreme caution with this because once they are removed, they are gone.

    exim -Mrm %messageid%

    Will remove %messageid% from the mail queue.

    xargs -n1

    is taking each message id you get from the exiqgrep -if %envelope-sender% command and passing it as the next argument to exim -Mrm. Essentially exim -Mrm %messageid1%, exim -Mrm %messageid2%, exim -Mrm %messageid3%....
     
  3. webdsn

    webdsn Active Member

    Joined:
    Mar 4, 2018
    Messages:
    29
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    Taiwan
    cPanel Access Level:
    Root Administrator
    Thanks for reply

    but have a problem here

    when I type

    exiqgrep -if %sender% or exim -bpc

    system respon response command not found
     
  4. sparek-3

    sparek-3 Well-Known Member

    Joined:
    Aug 10, 2002
    Messages:
    1,743
    Likes Received:
    110
    Trophy Points:
    343
    cPanel Access Level:
    Root Administrator
    You've either got something messed up with your PATH variable or you don't have exim installed. If it's the latter then you have other, more pressing issues.

    Are you accessing the server as root? Do you have root access to the server in question?
     
  5. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,744
    Likes Received:
    1,884
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,

    You could also try searching for messages you want to remove via "WHM >> Mail Queue Manager". There's a "Delete All" button that allows you to delete all of the messages from the search results.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. webdsn

    webdsn Active Member

    Joined:
    Mar 4, 2018
    Messages:
    29
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    Taiwan
    cPanel Access Level:
    Root Administrator
    Thanks cPanelMichael
    just loading heavy can't open WHM .
    So I want use console to delete queue.
    But that problem has resolve .
    $Path not include /usr/sbin
    but I can use direct command
    /usr/sbin/exim -bpc
    to use this
     
  7. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,744
    Likes Received:
    1,884
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hi @webdsn,

    I'm glad to see you were able to get the command working. Let us know if you have any additional questions.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice