Useful Exim Commands

Try it in our public cloud & Get $5 Credit
CLAIM NOW

Exim is a popular, powerful, freely-available mail transfer agent. It is incredibly flexible with regard to mail routing, and has a number of capabilities for checking incoming mail. It also has a rich command line user interface for handling various administrative tasks and failure conditions that may arise during its use. If you’re running an Exim system and need to perform various tasks on your mail queue, here are some of the most useful commands of which you should be aware.

Getting Started

To complete this guide, you will need the following:
• 1 Node (Cloud Server or Dedicated Server) with any Linux distribution installed.
• Exim correctly configured

The below examples assume you are actively sending and receiving mail with this Exim installation.

Tutorial

Say you have a message stuck in your mail queue. Delivery will generally be attempted on a regular interval, but you may also wish to force delivery immediately. For instance, a message may be stuck because of an intermittent connectivity issue that has since been resolved, or a configuration error that has been fixed.

You can act on the message queue as a whole. Here is how to get the number of messages in the queue.

exim -bpc

Likewise, this is how to list all emails your Exim installation has queued up for delivery.

exim -bp

Here is how you’d force delivery without waiting for the interval to elapse.

exim -M Message ID

Likewise, you may have many messages stuck in the mail queue. Here is how to force the entire queue to be attempted without waiting for the interval.

exim -qf

Delivery for a given message may be frozen if the failure is determined to be unrecoverable. Here is how to force delivery even in this instance.

exim -qff

Perhaps you aren’t certain why a given message can’t be delivered. You can check the general logs, but these tend to be noisy on active mail servers. Here is how you’d view the logs for just one message.

exim -Mvl MessageID

Sometimes a clue for delivery failure lies in the message content itself. Here is how you’d view the body of a message in the queue.

exim -Mvb MessageID

Likewise, the header may contain invalid information such as a malformed hostname. This command displays a message’s header.

exim -Mvh MessageID

A given message may be so badly malformed that you may wish to remove it from the queue entirely. Here is how that is done, without delivering an error message to the sender.

exim -Mrm MessageID

If an email in your queue is frozen, this is the command you’d use to delete it.

exim -bpr | grep frozen | awk {'print $3'} | xargs exim -Mrm

Or you may need to flush the entire queue.

exim -bp | exiqgrep -i | xargs exim -Mrm

Perhaps you don’t know an email’s message ID but do know its subject. The below command deletes queued emails with a specified subject.

grep -lr 'Delivery not authorized' /var/spool/exim/input/ | sed -e 's/^.*\/\([a-zA-Z0-9-]*\)-[DH]$/\1/g' | xargs exim -Mrm

Conclusion

These commands cover much of what is necessary to manage an Exim installation from the command line. With the above in mind, it is possible to diagnose any number of Exim configuration issues, as well as to address network and email connectivity issues that may arise during its use. If this guide was helpful to you, kindly share it with others who may also be interested.