Wednesday, June 1, 2016

EXIM



Managing and Clearing the Exim Mail Queue on a cPanel Server

When running a cPanel-based mail server, it’s not uncommon to encounter situations where the Exim mail queue grows unexpectedly—sometimes due to spam, mail loops, or misconfigured scripts. Regularly monitoring and clearing the mail queue is essential for maintaining a healthy email environment.

Here’s a step-by-step guide on how to view, analyze, and clear Exim’s mail queue using command-line tools

Step 1: Viewing the Exim Mail Queue

exim -bp

exim -bp | exiqsumm

root@vserver622 [~]# exim -bp | exiqsumm

Count  Volume  Oldest  Newest  Domain
-----  ------  ------  ------  ------

    1     740      2m      2m  alshirawi.ae
    1     677      2m      2m  yahoo.com
---------------------------------------------------------------
    2    1417      2m      2m  TOTAL

This quickly shows you which domains have messages stuck in the queue and how many there are.

 Step 2: Removing Messages from the Queue


exiqgrep -i|xargs exim -Mrm

exiqgrep -i lists all message IDs.

xargs exim -Mrm deletes each message by its ID.

If a message is locked, Exim will notify you (e.g., Message ... is locked). In this case, you may need to retry after a few minutes or investigate why the message is locked.

B. Alternative Bulk Removal Methods

exim -bp|grep "<"|awk {'print $3'}|xargs exim -Mrm


exim -bp | awk '/^ *[0-9]+[mhd]/{print "exim -Mrm " $3}' | bash

root@vserver622 [/usr/local/cpanel/whostmgr/bin]# exiqgrep -i|xargs exim -Mrm
Message 1b86cI-0000yS-EX is locked

Step 3: Verifying the Mail Queue is Cleared


 bashvserver622 [~]#  exim -bp | awk '/^ *[0-9]+[mhd]/{print "exim -Mrm " $3}' |

root@vserver622 [~]# exim -bp | exiqsumm

Count  Volume  Oldest  Newest  Domain
-----  ------  ------  ------  ------

    2    6553      2h      2h  pooae.com
    8    26KB      2h      2h  yahoo.com
---------------------------------------------------------------
   10    32KB      2h      2h  TOTAL

 Step 4: Removing Specific Locked Messages

root@vserver622 [~]# exim -Mrm 1b86cI-0000yS-EX
Message 1b86cI-0000yS-EX has been removed

root@vserver622 [~]# exim -bp | exiqsumm

Count  Volume  Oldest  Newest  Domain
-----  ------  ------  ------  ------

    1     740      0m      0m  alshirawi.ae
    1     677      0m      0m  yahoo.com
---------------------------------------------------------------
    2    1417      0m      0m  TOTAL

Conclusion

Regularly monitoring and managing the Exim mail queue is essential for email delivery health on any cPanel server. With these command-line tools, you can quickly identify, summarize, and clean up problematic or stuck mail, ensuring that your users experience reliable email service.



Pro Tip:

If you regularly encounter large queues or locked messages, investigate the root cause—check for scripts sending excessive mail, look for authentication issues, or consider rate limiting outbound mail to avoid future problems.

 

No comments:

Post a Comment