Exim mail server – commands
Introduction
Exim is a widely used mail transfer agent (MTA) on Linux servers, especially in cPanel/WHM environments. It is responsible for handling the sending, receiving, and routing of emails. Managing the mail queue and troubleshooting email issues using Exim commands is essential for maintaining smooth email delivery.
Prerequisites
Before using Exim commands, ensure the following:
- Root or sudo access to the server
- Basic knowledge of Linux command line
- Exim service installed and running
- Access to SSH terminal
- Understanding of message IDs and email queue
Implementation
1. Delete mails older than a day
exiqgrep -o 86400 -i | xargs exim -Mrm
2. View mails in queue for a specific user
exim -bp | grep $name
3. View message details
exim -Mvh $MSGID # View header
exim -Mvb $MSGID # View body
exim -v -M $MSGID # View transaction
exim -Mvb $MSGID # View body
exim -v -M $MSGID # View transaction
4. Force delivery of a message
exim -M $MSGID
5. Run mail queue manually
exim -qf # Force queue run
exim -qff # Force queue run including frozen mails
exim -qff # Force queue run including frozen mails
6. View logs for a message
exim -Mvl messageID
7. Remove or manage messages
exim -Mrm messageID # Remove message
exim -Mg messageID # Bounce message to sender
exim -Mg messageID # Bounce message to sender
8. Check queue statistics
exim -bpc # Total messages in queue
exim -bp # List messages
exim -bpr | grep “<“ | wc -l # Count queued mails
exim -bpr | grep frozen | wc -l # Count frozen mails
exim -bp # List messages
exim -bpr | grep “<“ | wc -l # Count queued mails
exim -bpr | grep frozen | wc -l # Count frozen mails
9. Delete frozen messages
exim -bpr | grep frozen | awk ‘{print $3}’ | xargs exim -Mrm
10. Delete emails from specific sender
exiqgrep -i -f ‘<user@example.com>’ | xargs exim -Mrm
11. Update Exim
/scripts/eximup –force
Conclusion
Exim commands provide powerful control over email queue management and troubleshooting. By using these commands, administrators can monitor, manage, and resolve email delivery issues effectively. Regular maintenance of the mail queue helps ensure optimal server performance and prevents email-related problems.
