What is Exim? Exim is the maximum popular message transfer agent (MTA) with a completely effective and flexible MTA and makes use of it on one-of-a-kind systems.

If you use Exim with your cPanel server, you could do many things via your WHM interface, how can you manage Exim via your terminal? Check the following commands:

Test the dimensions of the mail queue:

exim -bpc                

Take a look at messages inside the queue:

exim -bp                  

Get a structured recap of the messages in the queue:

exim -bp | exiqsumm

Dispose of emails sent from domain.com:

exiqgrep -i -f domain.com | xargs exim -Mrm

Remove emails sent to domain.com:

exiqgrep -ir domain.com | xargs exim -Mrm

The number of emails per email account:

exim -bpr | grep "<" | awk {'print $4'} | cut -d "<" -f 2 | cut -d ">" -f 1 | sort -n | uniq -c | sort -n

Test the Exim log for emails generated from folders/scripts (CWD):

grep "cwd=/home" /var/log/exim_mainlog | grep -v Cron | awk '{for(i=1;i<=10;i++){print $i}}' | sort | uniq -c | grep cwd | sort -n

awk '{ if ($0 ~ "cwd" && $0 ~ "home") {print $3} }' /var/log/exim_mainlog | sort | uniq -c | sort -nk 1

grep 'cwd=/home' /var/log/exim_mainlog | awk '{print $3}' | cut -d / -f 3 | sort -bg | uniq -c | sort -bg

Discover any emails generated by PHP script presently in the mail queue:

egrep -R "X-PHP-Script" /var/spool/exim/input/*

Top 50 usage:

eximstats -ne -nr /var/log/exim_mainlog

IPs connected on port 25 - this isn't specifically an Exim command however it's far beneficial for troubleshooting email problems:

netstat -plan | grep :25 | awk {'print $5'} | cut -d: -f 1 | sort | uniq -c | sort -nk 1

Discover all messages sent as "nobody":

ps -C exim -fH ewww | awk '{for(i=1;i<=40;i++){print $i}}' | sort | uniq -c | grep PWD | sort -n

Mail queue summary:

exim -bpr | exiqsumm -c | head

Shows messages headers:

exim -Mvh messageid

Body of the message:

exim -Mvb message id