This tutorial covers essential Exim mail server commands for managing queues, restarting services, repairing issues, rebuilding databases, and migrating mail configurations. Ideal for sysadmins and email server managers.
1. Check Exim Version
exim -bV
This displays the version of Exim installed and compiled options.
2. View the Mail Queue
exim -bp
Displays the mail queue in summary format.
mailq
Alias for exim -bp
, lists queued mails.
3. Count Messages in Queue
exim -bpc
Outputs the total number of messages currently in the queue.
4. View Details of a Specific Message
exim -Mvh <message-id>
Shows headers of a queued email.
exim -Mvb <message-id>
Shows the body of the queued email.
5. Force Delivery of a Message
exim -M <message-id>
Attempts to deliver the specified message immediately.
6. Force Delivery of All Queued Messages
exim -qff
Forces a queue run and attempts to deliver all messages.
7. Remove a Specific Message from Queue
exim -Mrm <message-id>
Deletes a specific message from the queue.
8. Remove All Messages from Queue
exiqgrep -i | xargs exim -Mrm
Deletes all queued emails. Use with caution.
9. List Frozen Messages
exim -bp | grep frozen
Lists emails that are frozen (cannot be delivered).
10. Remove All Frozen Messages
exiqgrep -z -i | xargs exim -Mrm
Removes all frozen messages from the queue.
11. Pause/Freeze a Message
exim -Mf <message-id>
Freezes a message so it won't be retried until manually unfrozen.
12. Unfreeze a Message
exim -Mt <message-id>
Thaws a frozen message so it can be delivered again.
13. Restart Exim Service
systemctl restart exim
For systemd-based systems (e.g., CentOS 7+, Ubuntu 18.04+).
/etc/init.d/exim restart
For older init-based systems.
14. Rebuild Exim Configuration (if applicable)
/scripts/buildeximconf
For cPanel servers, rebuilds Exim configuration files.
15. Reconfigure Mail System (Debian-based)
dpkg-reconfigure exim4-config
Interactive reconfiguration on Debian/Ubuntu.
16. Migrate Mail Logs or Spool
To move Exim spool (message queue) to a new location:
service exim stop mv /var/spool/exim /new/location/exim ln -s /new/location/exim /var/spool/exim service exim start
Ensure permissions are maintained and that Exim has access to the new location.
17. View Exim Logs
tail -f /var/log/exim/mainlog
Real-time view of mail transactions.
tail -f /var/log/exim/paniclog
Check for critical errors.
tail -f /var/log/exim/rejectlog
Check for rejected emails.
18. Basic Troubleshooting Commands
exim -bt user@example.com
Test how Exim would route email to a specific address.
exim -d -bt user@example.com
Verbose debug output of the routing test.
19. Useful grep-based Message Filters
List messages sent from a specific sender:
exiqgrep -f sender@example.com
List messages to a specific recipient:
exiqgrep -r recipient@example.com
List messages older than 1 day:
exiqgrep -o 86400
20. Queue Runner Manual Start
exim -q
Processes all queued messages (regular delivery).
21. Queue Runner in Background
exim -q &
Run queue delivery in the background.
22. Filter and Delete Queue Based on Time
Delete messages older than 7 days:
exiqgrep -o 604800 -i | xargs exim -Mrm
23. Notes on Migration
For full server migration:
- Copy configuration:
/etc/exim/exim.conf
or/etc/exim4/
- Copy mail spool:
/var/spool/exim/
- Copy mail logs:
/var/log/exim/
Ensure permissions and ownership match after copying files.
Conclusion
Exim is a powerful MTA. Mastering these basic commands gives you full control over mail delivery, troubleshooting, and system maintenance. Always back up critical configs before making major changes.