If you’re managing an Exim mail server, you’ll inevitably need to perform various maintenance and troubleshooting tasks. Over my nine years of server administration, I’ve found certain commands particularly useful. This guide shares those essential Exim commands that have consistently proven their value in managing mail servers effectively.

Monitoring Current Activity

To get a real-time snapshot of what Exim is currently doing:

exiwhat

This command provides an immediate overview of Exim’s current processes, showing you what the mail server is handling at that precise moment.

Analyzing the Mail Queue

Count Messages in the Queue

One of the first indicators of potential problems is an unusually large mail queue. To get a simple count of messages currently in the queue:

exim -bpc

For effective monitoring, run this command several times over a few hours to establish whether the queue is growing, which could indicate a delivery issue.

Detailed Queue Analysis

For a more comprehensive analysis of your mail queue, including size and age statistics:

exim -bp | exiqsumm

This powerful combination displays:

  • Total message count
  • Queue volume
  • Age of oldest and newest messages
  • Destination domains
  • Summary statistics

The “oldest message” and “volume” metrics are particularly useful for identifying problematic domains or persistent delivery issues.

Managing the Mail Queue

Process the Entire Queue

To trigger an immediate delivery attempt for all queued messages with verbose output:

exim -q -v

This instructs Exim to process the entire queue according to its standard delivery rules, with the -v flag providing detailed information about each delivery attempt.

Process Only Local Mail

If external mail is causing blockages, you can prioritize the delivery of local mail (such as system notifications):

exim -ql -v

This command attempts to deliver only messages addressed to local recipients, which can help clear important internal communications when external delivery is experiencing issues.

Clean Up Old Messages

To remove messages that have been stuck in the queue for extended periods (potentially spam or bounces):

exiqgrep -o 604800 -i | xargs exim -Mrm

This command finds and removes all messages older than 7 days (604,800 seconds). Adjust the time value as needed—it’s calculated as seconds per day (86,400) multiplied by the number of days.

Final Thoughts

While Exim offers many more specialized commands, these are the ones I’ve found most useful in day-to-day server administration. They provide a solid foundation for monitoring, troubleshooting, and maintaining your Exim mail server.

For specific issues or advanced configurations, Exim’s comprehensive documentation is an excellent resource. However, these commands should handle the vast majority of routine mail server management tasks you’re likely to encounter.