Tuesday, September 12, 2023

mail queue issues EXIM in CPanel

Today, I have sudden issues with the Email server in Cpanel. As we know Cpanel is using EXIM as MTA. The issue was the sudden full of hard disk of the /var.  After basic troubleshooting of the logs file, I found there was a huge mail queue in the list causing /var/log/exim/input and msglog files huge sizes. 
Firstly, I deleted the files inside the input and msglogs to make some space-free. After that, I used the following command to check the mail queue.

system@system.com# exim -bp
23h       1qffqz-0002bF-0E <sandesh@abc.com>
          donj.cheri@gmail.com
          jakal_6@libero.it
          cf@fritzsche-baurecht.ch
          carlotuti@libero.it
          info@eigenheim-messen.ch
          jonny318it1800@yahoo.it
          centro@universoturismo.it
          paolaviola3@virgilio.it
          italiamassimo@yahoo.it
          ermacal5@libero.it
          chrkaelin@sunrise.ch
          pierguidi@interfree.it
          saviox@alice.it
          angelo_galassi@fastwebnet.it


This user has around 67k emails in the queue. To remove all the mail of that user I used the following command

system@system.com#exiqgrep -i -f sandesh@abc.com | xargs exim -Mrm

This command deletes all the queue emails sent by this user. After that, I suspended the user and changed the password for further troubleshooting.


For more commands:


To display the number of emails in the queue we use the command

exim -bpc

To count the emails for a particular sender we use the command

exim -bp|grep "<"|grep $user-name|wc -l

Recently one of our customers contacted us to delete all the mails in his mail queue with Exim command. Let us discuss how our Support Engineers use Exim commands to delete the queue.

 

Exim delete mail queue


To remove all messages from the queue, we use the below command.

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

or

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

In this method, the command ‘exim -bp’ is used to find-out the message ID from the Exim mail queue.

And then remove the corresponding email from the mail queue by using the command ‘exim -Mrm’ as an argument.

We also use exiqgrep command to delete the mail queue.

exiqgrep -i | xargs exim -Mrm

 

Also, To remove a message from the queue, we use the command.

exim -Mrm {message-id}

 

Similarly, to remove all emails from a particular user from the queue.

exiqgrep -i -f $user | xargs exim -Mrm

 

Also, to remove all frozen messages, we use the below commands.

exiqgrep -z -i | xargs exim -Mrm
Read more ...