I took inspiration from this post on StackOverflow while debugging connectivity issues on a mail server I manage.

You can start up another instance of exim listening on a non-standard port, then connect to that instance and observe the console ouput to determine what the problem is.

root@server:~# exim -bd -d -oX 26

You can then configure your mail program to deliver via tcp/26 and see what happens.

However, to make it easier I introduced two more tools:

  • swaks - command line tool to deliver test emails
  • awk - to prefix each line of output with a timestamp (I also found that the “ts” command from the gnu moreutils package will do this but I didn’t try it)

So, the command to start the server then became:

root@server:~# exim -bd -d -oX 26 2>&1 | awk '{ print strftime("%Y-%m-%d %H:%M:%S"), $0; fflush(); }' | tee -a debug.log

Note the 2>&1 redirects error output to stdout (so that it can be piped into the awk). The awk then prints the time at the start of each line and the tee -a appends the output to debug.log for later viewing.

Now with swaks - either locally or on a remote machine you can deliver a test message:

root@server:~# swaks --to email@domain.com --server --port 26

Once the message has been delivered you can shut down the exim command on the server (^C) and inspect the debug.log file. Rinse and repeat.