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.

Notification if Mail Queue Manager pass 100 emails

Discussion in 'E-mail Discussions' started by Diego.Vieira, Jan 21, 2012.

  1. Diego.Vieira

    Diego.Vieira Member

    Joined:
    Jul 19, 2010
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    It's possible to get a notification if Mail Queue Manager pass 100 emails?
    thanks
     
  2. yapluka

    yapluka Well-Known Member

    Joined:
    Dec 24, 2003
    Messages:
    301
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    France
    cPanel Access Level:
    Root Administrator
    CSF will do what you want... among many other things :)
     
  3. Diego.Vieira

    Diego.Vieira Member

    Joined:
    Jul 19, 2010
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    Thanks much!
     
  4. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    You could cron run a script like the following:

    Code:
    #!/bin/bash
    if [ `exim -bpc` -ge 100 ] 
    then echo "Exim queue at `exim -bpc`" | /bin/mail -s "Exim queue" myuser@mydomain.com
    else
    :
    fi
    The file could be called /root/eximqueue.sh and would need to be executable to run:

    Code:
    chmod +x /root/eximqueue.sh
    You could then put it into /var/spool/cron/root file to run every 15 minutes using this command:

    Code:
    */15 * * * * /root/eximqueue.sh
     
    #4 cPanelTristan, Jan 23, 2012
    Last edited: Jan 23, 2012
  5. Diego.Vieira

    Diego.Vieira Member

    Joined:
    Jul 19, 2010
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    Thanks a lot!
     
  6. osirion

    osirion Active Member

    Joined:
    Jan 16, 2007
    Messages:
    28
    Likes Received:
    1
    Trophy Points:
    3
    I tried the above script and its setup properly (cron / perms) but its not working. Anyone have something that would work? Im on CentOS...
     
  7. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,767
    Likes Received:
    662
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  8. osirion

    osirion Active Member

    Joined:
    Jan 16, 2007
    Messages:
    28
    Likes Received:
    1
    Trophy Points:
    3
    I'm using one provided by my supplier, to move over to CSF is going to be a bit of a headache. Was hoping I could get a bash script going so long though
     
  9. osirion

    osirion Active Member

    Joined:
    Jan 16, 2007
    Messages:
    28
    Likes Received:
    1
    Trophy Points:
    3
    Managed to get my hands on this:

    Code:
    #!/bin/bash
    
    ######### Edit here ##########
    
    _mail_user=someone@bob.com # Set this to your email id to receive alerts on mail queue
    _limit=100 # Set the limit here
    
    ##############################
    
    clear;
    _result="/tmp/eximqueue.txt"
    _queue="`exim -bpc`"
    
    if [ "$_queue" -ge "$_limit" ]; then
    echo "Current queue is: $_queue" > $_result
    echo "Summary of Mail queue" >> $_result
    echo "`exim -bp | exiqsumm`" >> $_result
    mail -s "Number of mails on `hostname` : $_queue" $_mail_user < $_result
    cat $_result
    fi
    
    rm -f $_result
    Works like a charm. Now I just have one question for someone slightly more advanced than me. Assuming the queue has exploded with spam, above message will just be in the back of the queue - so we would want to force it to be sent before anything else essentially.
    From my understanding, we can use the following to force delivery of one message:
    Code:
    /usr/sbin/exim  -M  email-id
    Anyone here know how I could extract the email-id from the scripts mail function and then run the above command with it?
    Something along the lines of:
    Code:
    _message_id = "'exiqgrep -f root@hostname'"
    /usr/sbin/exim  -M  "$_message_id"
    
     
  10. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,767
    Likes Received:
    662
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    It should send out on the first delivery attempt instead of staying in the mail queue. The mail in the queue typically failed on the initial attempt to deliver the message.

    Thank you.
     
Loading...

Share This Page