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 email in queue

Discussion in 'E-mail Discussions' started by marlowmedia, Oct 25, 2016.

Tags:
  1. marlowmedia

    marlowmedia Member

    Joined:
    Oct 25, 2016
    Messages:
    11
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    Wigan
    cPanel Access Level:
    Root Administrator
    Hi,

    We are an Email Marketing company, we send over a million emails out every month to our subscribers and are also Return Path Certified. We recently came into an issue with our server provider with AOL and have had to block emails being sent out to AOL servers by blocking our server from connecting to AOL servers. We now have over 1 million emails in our queue and is causing our server some issues such as the following:

    System Information

    System Item
    Details Status
    Server Load 66.524414 (8 CPUs)
    Memory Used 97.17% (7,803,856 of 8,030,740)
    Swap Used 26.73% (2,242,268 of 8,388,600)

    I'm guessing this is because of Exim and our high mailing queue as we've never had this problem before. What is the best way to delete all emails in the queue to domains such as aol.com and aim.com?

    Our email queue size is the following: 1,485,468.

    Also how do i perform a shell command to run everyday to delete aol.com and aim.com emails from the queue so that the build up doesnt happen again? Also if theres a better way of stopping emails being sent to aol server (instead of blocking the IPs of AOL servers) then that would be great (server-side).

    Any help would be much appreicated!

    Thanks.
     
  2. SysSachin

    SysSachin Well-Known Member

    Joined:
    Aug 23, 2015
    Messages:
    542
    Likes Received:
    39
    Trophy Points:
    28
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,

    If you just want to reomve mail from the server mail queue then use below command to remove all AOL mails
     
  3. marlowmedia

    marlowmedia Member

    Joined:
    Oct 25, 2016
    Messages:
    11
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    Wigan
    cPanel Access Level:
    Root Administrator
    I've ran the ssh commend and its been running for 2hrs and 30mins now but my mail queue is still not going down, what can i do to decrease the server load, will turning exim off help at all? if i turn it off then will the ssh command still work?

    Its done nothing for over 2hrs now :(

    PS: i ran the code before it was posted as i found how to do it around 5mins after posting this topic.

    Thanks,
    Mike
     
  4. Vishnu Pradeep

    Vishnu Pradeep Registered

    Joined:
    Oct 9, 2016
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Hello Marlow,

    Saw your query on clearing up the exim queue and I would recommend to make use of a custom script that will run as a cron job everyday.

    1. Create a file to specify the domains: /usr/local/src/mail_domains.txt

    eg. You can add "aol.com" and "aim.com" to this file. Also, you can add "frozen" or "<>" into this file if you wish to clear frozen mails from the queue.

    2. Next create a custom script with contents given below: /root/clear_queue.sh

    Code:
    #######
    
    #!/bin/bash
    
    ##Read the domains
    for i in `cat /usr/local/src/mail_domains.txt`
    do
    sleep 5
    ##Clear the mails with respect to each domain
    exim -bpr | grep "$i" | awk {'print $3'} | xargs exim -Mrm
    sleep 5
    done
    
    ######
    
    3. Give the script executable permission

    chmod 755 /root/clear_queue.sh

    4. Run the script as a cron job, (Assuming 11:00 PM is your off-peak hours)

    Edit the cron jobs:

    crontab -e

    Then add the following cron job as below:
    Code:
    0 23 * * * /root/clear_queue.sh >/dev/null 2>&1
    
    Final note: The above method will be an unattended method to clear up all the mails. Regarding your query with high load in the server, it is because that the entire mail queue has to be processed where at the same time the queue is growing. If by any circumstance the load becomes too high to manage and the servers goes down due to it, we have to implement a different strategy by removing the queued mails from the directory. Please review the above and let me know your thoughts.

    Off topic: Also, how do you manage to keep your mail IP from blacklisting or do you make use of any IP rotation.

    Warm Regards,
    Vishnu Pradeep
     
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,064
    Likes Received:
    1,287
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    You can setup a custom Exim system filter that rejects messages sent to certain domain names. Information on how to setup a custom Exim system filter is available at:

    How to Customize the Exim System Filter File - cPanel Knowledge Base - cPanel Documentation

    This document is useful when setting up custom filter rules:

    How to Configure Mail Filters - cPanel Knowledge Base - cPanel Documentation

    You may also find these links helpful:

    Delete mails in queue with terminal
    How to Prevent Email Abuse - cPanel Knowledge Base - cPanel Documentation

    Thank you.
     
Loading...

Share This Page