Test validity of email address from the command line with exim

Posted in Email Servers and Linux/Unix/BSD -

While trying to troubleshoot why email wasn't being delivered to one of my mail aliases on a new server this morning, I discovered a nifty little trick for testing the deliverability of an email address using exim from the command line.

exim -bt command line flag

From the command line enter "exim -bt" followed by the email address to test as shown in the example below, where I was testing the email address minerva@nz1.minervamail.com:

exim -bt minerva@nz1.minervamail.com

Mail to that domain was handled by the localhost and there was a system alias set up to send all mail to the "minerva" user to my email address. Unfortunately I had mis-typed my own email address in the /etc/aliases file so got the following result:

R: system_aliases for minerva@nz1.minervamail.com
R: dnslookup for chris@isavvy.co.nc
chris@isavvy.co.nc is undeliverable: Unrouteable address
    <-- minerva@nz1.minervamail.com

Until I worked out how to do this, I had been confused about why mail was bouncing as the mail system appeared to be all set up correctly. It was only when doing this test that I saw it was actually the forwarding address causing the error.

After correcting the alias, running newaliases and trying again:

R: system_aliases for minerva@nz1.minervamail.com
R: dnslookup for chris@isavvy.co.nz
chris@isavvy.co.nz
    <-- minerva@nz1.minervamail.com
  router = dnslookup, transport = remote_smtp
  host aspmx.l.google.com      [74.125.95.27]  MX=10
  host alt1.aspmx.l.google.com [74.125.47.27]  MX=20
  host alt2.aspmx.l.google.com [74.125.115.27] MX=20
  host aspmx3.googlemail.com   [72.14.213.27]  MX=30
  host aspmx5.googlemail.com   [74.125.157.27] MX=30
  host aspmx4.googlemail.com   [209.85.229.27] MX=30
  host aspmx2.googlemail.com   [74.125.43.27]  MX=30

Some other examples

You can also use it for testing deliverability of remote addresses to, e.g.:

$ exim -bt test@example.com
R: dnslookup for test@example.com
test@example.com
  router = dnslookup, transport = remote_smtp
  host example.com [2001:500:88:200::10] 
  host example.com [192.0.43.10]   

and an invalid format address:

$ exim -bt test@@example.com
syntax error: domain missing or malformed

and another example:

$ exim -bt test@test@example.com
syntax error: malformed address: @example.com may not follow test@test

and finally an example where MX records aren't set up for the host:

$ exim -bt foo@bar.com 
R: dnslookup for foo@bar.com
foo@bar.com is undeliverable: all relevant MX records point to non-existent hosts


Related posts:


Comments