List of Useful Exim Commands

List of Useful Exim Commands

Written by Bobby Iliev on Jun 29th, 2020 Views Report Post

Introduction

Exim is one of the most popular message transfer agent (MTA). It is widely used on different systems and is the goto message transfer agent for most cPanel servers.

Exim was developed at the University of Cambridge for use on Unix systems.

It is an open-source project with the terms of the GNU General Public Licence.

Exim is a very powerful and flexible MTA and is often installed in place of Sendmail, although the configuration of Exim is quite different.

Useful Exim Commands

If you are using Exim with your cPanel servers, you can do a lot of the tings through your WHM interface, however here's how you could manage exim via your terminal as well.

  • Check size of mail queue:
exim -bpc
  • Check messages in the queue:
exim -bp
  • Get structured recap of the messages in the queue:
exim -bp | exiqsumm
  • Remove 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
  • 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
  • Check 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
  • Find any emails generated by a PHP script currently 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 is not particularly an exim command but it is useful for troubleshooting email problems:
netstat -plan | grep :25 | awk {'print $5'} | cut -d: -f 1 | sort | uniq -c | sort -nk 1
  • Find 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 

Conclusion

This is my personal Exim commands cheatsheet. I use these commands a lot when troubleshooting various problems with my mail servers.

I hope that you find this helpful!

Bobby

Comments (0)