Exim is a message transfer agent (MTA) for hosts that are highly comfortable and running in Unix or Linux Operating system. Exim server is developed at the University of Cambridge. We can easily manage and configure in server . In this post have shared few executable commands as below,

1.Find out number messages in queue:


# exim -bpc
120

2. List out all the messages from the queue

# exim -bp
1m   37K 1WsaJy-003biD-Kv <root@host.hostname.com>
          user@domain.com

3. Count the number of messages for each email id

#  exim -bp|grep "<"|awk {'print $4'}|cut -d"<" -f2|cut -d">" -f1|sort -n|uniq -c|sort –nr

  138 root@host.hostname.com
    6 admin@domain.com

We can easily count the number of sent  messages  for every user

4. View specific email logs

# exim -bp | grep 'username@domain.com' | awk '{ print $3; system("exim -Mvl "$3)}'

1WsQ3G-0004k4-4k
2014-06-05 10:47:22 Received from username@domain.com H=localhost…

5. Forcefully sending message from a domain

# exim -v -Rff  domain.com

LOG: MAIN
  cwd=/home 4 args: exim -v -Rff domain.com
LOG: queue_run MAIN
  Start queue run: pid=3152 -qff -R domain.com

6. View message content

# exim -Mvb 1WsQ3G-0004k4-4k        
             
1WsQ3G-0004k4-4k-D
GOOD DAY.
05 / 06 /2014
TO     : M/S THE LINUXFAQ, /  Israel , .

7. To remove frozen messages in queue

# exim -bpru|grep frozen|awk {'print $3'}|xargs exim -Mrm
Message 1WsaoQ-003jB2-BA has been removed ....

(or)

# exiqgrep -zi | xargs exim -Mrm 

8. Remove specific email from queue:

# /usr/sbin/exiqgrep -i -f "root@host3.hostname.com" | xargs /usr/sbin/exim -Mrm
Message 1Wso97-000USt-Uc has been removed

(or)

# exim -bp | grep 'root@host3.hostname.com' | awk '{ print $3; system("exim -Mrm "$3)}'

9. Remove a particular message from queue:

# exim -v -Mrm 1WsdRy-0006Ws-9T

LOG: MAIN
  cwd=/home 4 args: exim -v -Mrm 1WsdRy-0006Ws-9T
Message 1WsdRy-0006Ws-9T has been removed
LOG: MAIN
  removed by root
LOG: MAIN
  Completed

10. Reports what Exim is doing currently

# exiwhat

127081 daemon: -q1h, listening for SMTP on port 25 (IPv6 and IPv4) port 587 (IPv6 and IPv4) and for SMTPS on port 465 (IPv6 and IPv4)
132119 handling incoming connection from [222.11.48.52]:28290
132563 handling incoming connection from [88.249.64.158]:2747
133732 handling incoming connection from [123.16.74.242]:12373

11. Remove 7 days(d)  or 7 hours(h)  or  7 minutes(m) old messages from queue

# exim -bpr | grep 7d | awk {'print $3'} | xargs exim -Mrm;

# exim -bpr | grep 7h | awk {'print $3'} | xargs exim -Mrm;

# exim -bpr | grep 7m | awk {'print $3'} | xargs exim -Mrm;

12. filter specific message id

# grep -lr 'root@host4.hostname.com'  /var/spool/exim/input/ |  sed -e 's/^.*\/\([a-zA-Z0-9-]*\)-[DH]$/\1/g'

1Wt9H1-001ziQ-PT
1WtAu1-002OG4-RD

13. Remove all filtered messages from queue

# grep -lr 'root@host4.hostname.com'  /var/spool/exim/input/ |  sed -e 's/^.*\/\([a-zA-Z0-9-]*\)-[DH]$/\1/g' |  xargs exim -Mrm

Message 1Wt9H1-001ziQ-PT has been removed
Message 1WtAu1-002OG4-RD has been removed

14. View the header of message

# exim -Mvh 1WtDDk-0030bx-Kw

1WtDDk-0030bx-Kw-H
root 0 0
<root@host4.hostname.com>
1402134448 0


15. To get summary of messages from the queue (like, Count  Volume  Oldest  Newest  Domain)

# exim -bp | exiqsumm

Count  Volume  Oldest  Newest  Domain
-----  ------  ------  ------  ------

    1    7987     21h     21h  mymail.com
    2    1472      0m      0m  domain.com
    1     990     19h     19h  whoarmail.net
---------------------------------------------------
    4    10KB     21h      0m  TOTAL

16. View all exim configuration settings

# exim -bP

accept_8bitmime
acl_not_smtp = acl_not_smtp
acl_not_smtp_mime =
acl_not_smtp_start =
acl_smtp_auth =
acl_smtp_connect = acl_smtp_connect
acl_smtp_data = acl_smtp_data

17. Filder the most email IP address from log

# tail -1000 /var/log/exim_mainlog |grep  '\[' |cut -d[ -f2 |cut -d] -f1|sort -n |uniq -c 
             
      1 192.168.0.11
      2 192.168.0.12
      1 192.168.0.13
      3 192.168.0.14

18. Get Exim statistics from the mainlog files.

# eximstats /var/log/exim_mainlog

Exim statistics from 2014-06-01 03:19:09 to 2014-06-07 16:19:12

19.Force delivery of an email:

# exim -M message-id

20. Force another queue run:

# exim –qf

21. Find out Exim verion

# exim -bV
-i print messages id
-f from address
-Mrm remove mails
-t to address