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.

Insted of using WHM --> Mail Queue Manager, what would be the shell equivalent for this?

Discussion in 'E-mail Discussions' started by jols, Sep 27, 2014.

  1. jols

    jols Well-Known Member

    Joined:
    Mar 13, 2004
    Messages:
    1,111
    Likes Received:
    2
    Trophy Points:
    38
    I'd dearly like to do enter a command line, or set up a shell script to do the same as this action in in WHM --> Mail Queue Manager:

    Search (From header) for "AHSWarranty" then delete any such email found.

    Possible? Is there are pre-built script for this somewhere on the server so such a thing could be done without using the WHM interface?
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  3. jols

    jols Well-Known Member

    Joined:
    Mar 13, 2004
    Messages:
    1,111
    Likes Received:
    2
    Trophy Points:
    38
    Thanks very much.

    I'm getting very close to do what I need, but keep running into the same error.

    At shell, after running this:

    Code:
    grep -R -l YourCoffeeRewards /var/spool/exim/msglog/*|cut -b26-|xargs exim -Mrm

    I get this:

    exim: no message ids given after -Mrm option


    And if I run this:

    Code:
    exim -Mrm `grep -lr 'YourCoffeeRewards' /var/spool/exim/input/ | sed -e 's/^.*\/\([a-zA-Z0-9-]*\)-[DH]$/\1/g'` 2> /dev/null

    I get a page or two of this:
    Code:
    Message 1XYeNj-001Ejg-Ro has been removed or did not exist
    Spool data file for 1XYeNj-001Ejg-Dy does not exist
    Continuing, to ensure all files removed
    Spool read error for 1XYeNj-001Ejg-Dy-H: No such file or directory
    Continuing to ensure all files removed
    Message 1XYeNj-001Ejg-Dy has been removed or did not exist
    Spool data file for 1XYeRt-001QEq-FW does not exist
    Continuing, to ensure all files removed
    Spool read error for 1XYeRt-001QEq-FW-H: No such file or directory
    Continuing to ensure all files removed
    Message 1XYeRt-001QEq-FW has been removed or did not exist

    But still, tons of email from "YourCoffeeRewards" remains in the queue.

    And if I just run this:

    grep -lr 'YourCoffeeRewards' /var/spool/exim/input/

    I get many, many hits, like so:

    Code:
    /var/spool/exim/input/p/1XYeSp-001WFj-9b-H
    /var/spool/exim/input/v/1XYeSv-001WHe-6Z-H
    /var/spool/exim/input/i/1XYeOi-001Gi6-J0-H
    /var/spool/exim/input/9/1XYeO9-001ErJ-3n-H
    /var/spool/exim/input/U/1XYeOU-001Evt-NR-H
    /var/spool/exim/input/U/1XYeSU-001Qwd-Md-H
    /var/spool/exim/input/T/1XYeOT-001Evg-Kd-H
    /var/spool/exim/input/S/1XYeQS-001Ki3-3j-H

    So I am still wondering how, for example, I can get exim to just delete any email from "YourCoffeeRewards" via the command line?
     
  4. jols

    jols Well-Known Member

    Joined:
    Mar 13, 2004
    Messages:
    1,111
    Likes Received:
    2
    Trophy Points:
    38
    Oddly, this seems to work on the Pending Queue, but not the Delivery Queue (yes, I have ConfigServer Mail Queues installed):

    exiqgrep -i|xargs exim -Mrm `grep -lr 'example.com' /var/spool/exim/input | sed -e 's/^.*\/\([a-zA-Z0-9-]*\)-[DH]$/\1/g'` 2> /dev/null
     
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    You can always formulate commands without "exim -Mrm" to get a better idea of what the search output is before you delete the actual messages.

    Thank you.
     
  6. jols

    jols Well-Known Member

    Joined:
    Mar 13, 2004
    Messages:
    1,111
    Likes Received:
    2
    Trophy Points:
    38
    Thanks, but the confounding issue here is this, I believe, since I use the Configsever Mailscanner system, the exim queues are divided into two parts:

    Delivery Queue - (described as) Default queue - email waiting for delivery
    Pending Queue - (described as) Email awaiting processing by MailScanner

    So effectively all exim commands look at the wrong queue, that is, the Pending Queue rather than the (usually) thousands of messages stacked up in the Delivery Queue.

    Case in point:

    When I enter this:

    exim -bp

    Or any exim command that takes a tally of the messages in the queue, it always gives stats for the Pending rather than the Delivery queue.

    So may simple, yet, apparently very challenging quest is to come up with a shell command that will grep then remove messages from the Delivery Queue which contain certain keywords, or are from certain email addresses.

    Also note: The built in WHM ---> Mail Queue Manager will indeed, tally the messages and allow operations on the Delivery Queue. So again, I am unable to even get a starting point with an exim command that will at least "look at" the proper queue on the server.
     
  7. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    You may need to temporarily disable MailScanner so you can remove certain messages from the queue if it's interfering with your ability to do so. Or, you may need to consult with MailScanner's documentation to see if there are any alternatives for removing specific emails.

    Thank you.
     
Loading...

Share This Page