CpanelLinuxlogs

How do I delete the pending mail in Exim queue?

In this article you will know how to delete the pending mail in exim queue.

In Exim, the mail queue is where messages that are pending delivery are stored. These could include emails that failed to send due to temporary issues, such as network problems, recipient server unavailability, or email throttling limits.

delete the pending mail in Exim

How do I delete the pending mail in Exim queue

You will first want to check the total count of emails in the queue to get a better understanding of how many emails you will be cleaning out with the following command:

exim -bpc

After determining the total number of emails, the exiqgrep command can be used to filter these messages:

Filter all frozen emails:

exim -bp| exiqgrep -z

Filter all unfrozen emails:

exim -bp| exiqgrep -x

Filter by the sender:

exim -bp| exiqgrep -f email@domain.tld

The output of the above commands will look similar to what’s below, with the time in queue, size, Exim message ID, sender, if the email is frozen or not, and the recipient.

19m 1.8K 1pcOAl-0004Ak-2w <email@domain.tld> *** frozen ***
root@hostname.domain.tld

After reviewing the emails you want to delete, you can just -i flag to return only the Exim message IDs and pipe the output into Exim to remove the email.

Please note these commands will remove ALL email from the mail queue that matches the filter, which may include legitimate emails. It is not possible to recover these emails once they have been deleted.

Delete all frozen emails:

exim -bp| exiqgrep -iz | xargs exim -Mrm 

Delete all unfrozen emails:

exim -bp| exiqgrep -ix | xargs exim -Mrm 

Delete all emails by the sender:

exim -bp| exiqgrep -if email@domain.tld | xargs exim -Mrm 

Common Reasons for Messages Remaining in the Queue

  • Temporary Failures: Issues like DNS resolution errors, recipient server downtime, or greylisting.
  • Permanent Failures: Incorrect recipient addresses, spam filters rejecting emails, or blacklisted IP addresses.
  • Rate Limits: If sending too many emails in a short time, the recipient server may delay further emails.
  • Spam Detection: If your server is flagged for spam, recipient servers may defer or reject emails.

By understanding the above article you will know how to delete the pending mail in Exim queue and diagnosing issues effectively, you can manage the Exim mail queue and ensure reliable email delivery.