Tech Support Notes

Exim

Exim is a mail transfer agent (MTA) used on Unix-like operating systems. Exim is free software distributed under the terms of the GNU General Public License, and it aims to be a general and flexible mailer with extensive facilities for checking incoming e-mail.

The Exim command

Print the Exim configuration with exim -bP

To test how exim will route a given address use the -bt flags:

exim -bt [email protected]
[email protected]
    -- [email protected]
  router = virtual_user, transport = virtual_userdelivery
[email protected]
    -- [email protected]
    -- [email protected]
  router = lookuphost, transport = remote_smtp
  host gmail-smtp-in.l.google.com      [2607:f8b0:4003:c02::1b] MX=5
  host gmail-smtp-in.l.google.com      [173.194.64.26]          MX=5
  host alt1.gmail-smtp-in.l.google.com [2607:f8b0:400d:c02::1b] MX=10
  host alt1.gmail-smtp-in.l.google.com [173.194.74.26]          MX=10
  host alt2.gmail-smtp-in.l.google.com [2607:f8b0:400c:c03::1a] MX=20
  host alt2.gmail-smtp-in.l.google.com [173.194.75.26]          MX=20
  host alt3.gmail-smtp-in.l.google.com [2a00:1450:400c:c03::1b] MX=30
  host alt3.gmail-smtp-in.l.google.com [173.194.78.26]          MX=30
  host alt4.gmail-smtp-in.l.google.com [2a00:1450:4013:c00::1b] MX=40
  host alt4.gmail-smtp-in.l.google.com [173.194.65.26]          MX=40

To print a count of the messages in the queue use exim -bpc

Print a summary of messages in the queue (count, volume, oldest, newest, domain, and totals):

exim -bp | exiqsumm

To print what Exim is doing right now use exiwhat

exiwhat
13759 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)

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 184.x.164.x

**** SMTP testing session as if from host 184.x.164.x
**** but without any ident (RFC 1413) callback.
**** This is not for real!

 host in hosts_connection_nolog? no (option unset)
LOG: SMTP connection from [184.x.164.x]
 host in host_lookup? no (option unset)
 host in host_reject_connection? no (option unset)
 host in sender_unqualified_hosts? no (option unset)
 host in recipient_unqualified_hosts? no (option unset)
 host in helo_verify_hosts? no (option unset)
 host in helo_try_verify_hosts? no (option unset)
 host in helo_accept_junk_hosts? yes (matched *)
 using ACL acl_smtp_connect
 processing accept
 check hosts = +trustedmailhosts
 sender host name required, to match against lsearch;/etc/trustedmailhosts
 looking up host name for x.x.x.x
 IP address lookup yielded x.x.x.x-static.reverse.alpaca.com
 gethostbyname2 looked up these IP addresses:
   name=x.x.x.x-static.reverse.alpaca.com address=x.x.x.x
 checking addresses for x.x.x.x-static.reverse.alpaca.com
   184.x.164.x OK
 host in lsearch;/etc/trustedmailhosts? no (end of list)
 host in +trustedmailhosts? no (end of list)
 accept: condition test failed in ACL acl_smtp_connect
 processing accept
 184.x.x.x in iplsearch;/etc/trustedmailhosts? no (end of list)
 check condition = ${if match_ip{$sender_host_address}{iplsearch;/etc/trustedmailhosts}{1}{0}}
                 = 0
 accept: condition test failed in ACL acl_smtp_connect
 processing accept
 check hosts = +relay_hosts : +loopback
 gethostbyname2 looked up these IP addresses:
   name=localhost.localdomain address=127.0.0.1
 host in net-iplsearch;/etc/relayhosts :  localhost : x.x.x.x? no (end of list)
 host in ; 127.0.0.0/8 ; 0.0.0.0 ; ::1 ; 0000:0000:0000:0000:0000:ffff:7f00:0000/8? no (end of list)
 host in +relay_hosts : +loopback? no (end of list)
 accept: condition test failed in ACL acl_smtp_connect
 processing accept
 check hosts = +relay_hosts : +backupmx_hosts
 host in lsearch;/etc/backupmxhosts? no (end of list)
 host in +relay_hosts : +backupmx_hosts? no (end of list)
 accept: condition test failed in ACL acl_smtp_connect
 processing accept
 check condition = ${if eq {$interface_port}{25}{no}{yes}}
                 = yes
 accept: condition test succeeded in ACL acl_smtp_connect
220-hostname.testingdomain.com ESMTP Exim 4.80.1 #2 Mon, 29 Jul 2013 19:59:21 -0500
220-We do not authorize the use of this system to transport unsolicited,
220 and/or bulk e-mail.
helo hostname.testingdomain.com
250 hostname.testingdomain.com Hello x.x.x.x-static.com [x.x.x.x]

Look at the headers of a message:

exim -Mvh MESSAGEID

Look at the body of a message

exim -Mvb MESSAGEID

exigrep

The exiqgrep utility is a Perl script which offers possibilities to grep in the exim queue output. Unlike exiqsumm, it invokes exim -bpu itself and does not need to be invoked in a pipe.

Use -f to search the queue for messages from a specific sender:

exiqgrep -f user@domain

Use -r to search the queue for messages for a specific recipient/domain:

exiqgrep -r otheruser@domain

Use -c to print a count of messages matching one of the other search terms:

exiqgrep -c -r [email protected]
5 matches out of 29 messages

Some additional flags

  • Use -o to print messages older than the specified number of seconds.
  • Use -y to print messages that are younger than the specified number of seconds
  • Use -s to match the size of a message with a regex

Exim Cheatsheet

Exigrep commands