Most of our Linux servers use Exim as the Mail Transfer Agent (MTA). Exim comes with a number of useful utilities you can use to manage the mail queue and troubleshoot email issues.
The utility you are likely to use most is
exigrep. In order to use that utility you need to understand Exim’s logs, and we therefore have written a separate article about Exim log files and exigrep.
Before we dive into the utilities, let’s make sure Exim is actually running. You can do so with the command
systemctl status exim or
systemctl is-active exim. Or, if you are old-school you might prefer
# systemctl is-active exim active # ps -C exim PID TTY TIME CMD 6746 ? 00:00:00 exim 6807 ? 00:00:00 exim 6871 ? 00:00:00 exim 15016 ? 00:03:32 exim
If Exim is not running your server may use another MTA. Of course, it can also be that the service is down. Running
systemctl is-enabled exim will tell you if Exim is enabled on your server (see our Managing services article for more information about systemd and systemctl).
Exim is a complicated piece of software. We won’t go into much detail about the configuration – contact us if you want the set-up to be changed on your server. We will give some quick pointers though.
In WHM, you find most of Exim’s configuration options under Service Configuration » Exim Configuration Manager. If anything needs to be tweaked, this is the preferred way to make changes.
If you want a summary of the current configuration then you can use the command
exim -bP. As the command produces lots of output we will just filter our some interesting settings:
# exim -bP | grep -E "^(daemon_smtp_ports|message_size_limit|recipients_max)" daemon_smtp_ports = 25 : 465 : 587 message_size_limit = 50M recipients_max = 0
The output shows the SMTP ports on which the Exim daemon listens; the maximum size an outgoing email can be and the maximum number of recipients (
0 indicates that no limit is enforced).
You can get basic information about all emails in the mail queue via
# exim -bp 4h 3.6K 1h1Gb3-00029f-NA <email@example.com> (example) firstname.lastname@example.org 52m 2.5K 1h1adA-00FjqU-L1 <email@example.com> (example) D firstname.lastname@example.org email@example.com ...
The output shows the following information on the first line:
The destination of an email is shown on the subsequent lines. The second email in the above example has two recipients. A
D in front of an email indicates that the email has delivered.
You can get a count of the number of emails in the queue by adding the
# exim -bpc 42
You can use the Exim ID to view or remove emails.
exim -Mvh– View the message headers
exim -Mvb– View the message body
exim -Mvc– View both the message headers and body
exim -Mrm– Remove (purge) the message
You can use the
exiqgrep utility to retrieve specific emails in the mail queue. It has got various useful options:
-f– Match the sender’s email address
-r– Match the recipient’s email address
-y– Match messages younger than [seconds]
-o– Match messages older than [seconds]
-z– Match frozen messages
-x– Match non-frozen messages
-c– Display a match count
-i– Display message IDs only
This gives you lots of options for grepping the mail queue. For instance, if you see lots of emails from firstname.lastname@example.org in the queue you can quickly get more information:
# exiqgrep -cf email@example.com 15 matches out of 38 messages # exiqgrep -zcf firstname.lastname@example.org 0 matches out of 38 messages # exiqgrep -xcf email@example.com 15 matches out of 38 messages
The output shows that there are 15 emails from firstname.lastname@example.org in the queue and that none of the emails has been frozen.
If you are sure that certain emails can be deleted then you can pipe the output of a
exiqgrep -i command to
exim -Mrm. For instance, to delete all emails in the queue with the sender email@example.com you can use this command:
# exiqgrep -if firstname.lastname@example.org | xargs exim -Mrm
Exim comes with a few other useful utilities.
exiqsumm is a script that reads the output of
exim -bp and produces a summary. You can’t run
exiqsumm on its own – instead you can pipe the output of
exim commands to the utility:
# exim -bp | exiqsumm -c Count Volume Oldest Newest Domain ----- ------ ------ ------ ------ 21 259KB 23h 52m example.net ...
Here, we added the
-c option to sort the domains by the number of emails. This can be useful way to quickly identify problematic domains.
Exim will try to deliver emails that are stuck in the queue at a later date. You can get more information about these redelivery attempts via the
# exinext email@example.com Transport: mail.example.com [188.8.131.52/NULL]:1j15Dg-005dkr-Ag error -18: H=mail.example.com [184.108.40.206]: Remote host closed connection in response to end of data first failed: 11-Feb-2020 18:42:18 last tried: 11-Feb-2020 19:43:08 next try at: 11-Feb-2020 19:58:08
Often the utlity won’t produce any meaningful output though: it only works if there is a specific error.
As mentioned in the introduction, we haven’t touched on the most-used utility yet:
exigrep. This utility works much like
grep but it is designed specifically to find information in the Exim logs. We have a separate article about Exim’s log files and exigrep.