Manage the Exim mail queue via SSH

In this article I'll review how to manage your Exim mail queue on your VPS (Virtual Private Server) or dedicated server via SSH. This will allow you to find out why sent messages haven't possibly been successfully delivered yet.

The MTA (Mail Transfer Agent) that runs on your server is called Exim and it controls your email deliveries. There are certain commands your can run over SSH that will allow you to manage the Exim mail queue and we'll be reviewing those below.

To follow this guide you'll have to have root access to either your VPS or dedicated server so you can access the Exim commands.

Viewing messages in the Exim mail queue

Using the steps below, I'll show you how to locate a message that we've attempted to send to user@example.com, but it hasn't arrived yet in that user's Inbox so we'd like to investigate why.

In this case we can see that there are 4 messages waiting to try to deliver to user@example.com, but they are all frozen. This means Exim has encountered an error while trying to deliver the message, and it has frozen it, until the next delivery retry time.

Now you can take one of the Exim message IDs from the queue and further investigate it in the Exim mail log as to why the message can't deliver with this command:

exigrep -I -l 1TwJlQ-0006MV-84 /var/log/exim_mainlog

This will give you back the full transaction of that message ID exposing