Exim is a message transfer agent (MTA) for use on Unix systems connected to the Internet. It is freely available under the terms of the GNU General Public Licence. In style it is similar to Smail 3, but its facilities are more general. There is a great deal of flexibility in the way mail can be routed, and there are extensive facilities for checking incoming mail. Exim can be installed in place of Sendmail, although the configuration of Exim is quite different.
We can easily manage exim via command line.We can easily remove mailqueues, If any particular user sending large number of emails we can easily find that account and remove it.
1. To get a count of messages in the queue
2. Print a listing of the messages in the queue (time queued, size, message-id, sender, recipient)
3. Print a summary of messages in the queue (count, volume, oldest, newest, domain, and totals):
exim -bp | exiqsumm
4. Print what Exim is doing right now:
5. Run a pretend SMTP transaction from the command line, as if it were coming from the given IP address. This will display Exim's checks, ACLs, and filters as they are applied. The message will NOT actually be delivered.
exim -bh 192.168.11.22
6. Display all of Exim's configuration settings:
Searching the queue with exiqgrep
Exim includes a utility that is quite nice for grepping through the queue, called exiqgrep. If you're not using this, and if you're not familiar with the various flags it uses, you're probably doing things the hard way, like piping `exim -bp` into awk, grep, cut, or `wc -l`. Don't make life harder than it already is.
First, various flags that control what messages are matched. These can be combined to come up with a very particular search.
7. Use -f to search the queue for messages from a specific sender:
exiqgrep -f [luser]@domain
8. Use -r to search the queue for messages for a specific recipient/domain:
exiqgrep -r [luser]@domain
9. Use -o to print messages older than the specified number of seconds. For example, messages older than 1 day:
exiqgrep -o 86400 [...]
10. Use -y to print messages that are younger than the specified number of seconds. For example, messages less than an hour old:
exiqgrep -y 3600 [...]
11. Use -s to match the size of a message with a regex. For example, 700-799 bytes:
exiqgrep -s '^7..$' [...]
Use -z to match only frozen messages, or -x to match only unfrozen messages. There are also a few flags that control the display of the output.
12. Use -i to print just the message-id as a result of one of the above two searches:
exiqgrep -i [ -r | -f ] ...
13. Use -c to print a count of messages matching one of the above searches:
exiqgrep -c ...
14. Print just the message-id of the entire queue:
Managing the queue
The main exim binary (/usr/sbin/exim) is used with various flags to make things happen to messages in the queue. Most of these require one or more message-IDs to be specified in the command line, which is where `exiqgrep -i` as described above really comes in handy.
15. Start a queue run
[email protected]# exim -q -v
16. Start a queue run for just local deliveries:
[email protected]# exim -ql -v
17. Remove a message from the queue:
[email protected]# exim -Mrm <message-id> [ <message-id> ... ]
18. Freeze a message:
[email protected]# exim -Mf <message-id> [ <message-id> ... ]
19. Throw a message:
[email protected]# exim -Mt <message-id> [ <message-id> ... ]
20. Deliver a message, whether it's frozen or not, whether the retry time has been reached or not:
[email protected]# exim -M <message-id> [ <message-id> ... ]
21. Deliver a message, but only if the retry time has been reached:
[email protected]# exim -Mc <message-id> [ <message-id> ... ]
22. Force a message to fail and bounce as "cancelled by administrator":
[email protected]# exim -Mg <message-id> [ <message-id> ... ]
23. Remove all frozen messages:
[email protected]# exiqgrep -z -i | xargs exim -Mrm
24. Remove all messages older than five days (86400 * 5 = 432000 seconds):
[email protected]# exiqgrep -o 432000 -i | xargs exim -Mrm
25. Freeze all queued mail from a given sender:
26. View a message's headers:
[email protected]# exim -Mvh <message-id>
27. View a message's body:
[email protected]# exim -Mvb <message-id>
28. View a message's logs:
[email protected]# exim -Mvl <message-id>
29. Add a recipient to a message:
[email protected]# exim -Mar <message-id> <address> [ <address> ... ]
30. Edit the sender of a message:
[email protected]# exim -Mes <message-id> <address>