Exim mail server Useful Commands

While the mailserver generally requires little interaction for those sending or receiving average volumes of email, there may be times when you wish to manage Exim’s settings.

To do so, first log in to your server in a terminal client using secure shell (SSH). Use the following commands to work with Exim.

Display the number of email messages in the queue

exim -bpc

Display information about email messages in the queue

exim -bp

Displays time queued, size, message-id, sender and recipient.

How to list email count with sender information from the Exim mail queue ?

We can use the base command “exim -bp” to do our concern. The output of the command “exim -bp” contains the user details, both sender and receiver email address. So, we can use it for our purpose. 🙂

Syntax:

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

Where;

exim -bp : Is the base command to list all email in the mail queue with its details.

grep “<” : To grep out the Sender address line only.

awk {‘print $4’} : Output only the sender name section.

cut -d”<” -f2|cut -d”>” -f1 : To crop ‘<‘ and ‘>‘ 🙂

sort -n|uniq -c|sort -nr : To re-arrange and count.

Example:

root@server# exim -bp|grep "<"|awk {'print $4'}|cut -d"<" -f2|cut -d">" -f1|sort -n|uniq -c|sort -nr
     15 root@domain0.com
     10 user@domain1.com
      8 user@domain2.com
      5 user@domain3.com
      3 user@domain4.com
      3 user@domain5.com
      2 user@domain6.com
      2 user@domain7.com

In this example, 15 emails are in the Exim mail queue for the account ‘root@domain0.com’ and 10 for the user ‘user@domain1.com’ and so on.

To count all emails from that user, you may use the exiqgrep command with -f switch.

exiqgrep -f sendername|grep "<"|wc -l

That’s it!

Display a summary of messages in the queue

exim -bp | exiqsumm 

Displays count, volume, oldest, newest, domain, and totals.

Display Exim’s current activity

exiwhat

exiwhat

Test Exim SMTP transaction

exim -bh ipaddress 

Spoofs an SMTP transaction, emanating from ipaddress. Exim’s status will be displayed as the transaction runs. Note that the message will not be delivered.

SMTP transaction

Display Exim settings

exim -bP

Exim settings

Search the mail queue for messages from a specific sender

exiqgrep -f [luser]@domain

Search the mail queue for messages from a specific recipient or domain

exiqgrep -r [luser]@domain

Display messages older than a specified number of seconds

exiqgrep -o seconds [...]

Display messages newer than a specified number of seconds 

exiqgrep -y seconds [...]

Locate messages matching a specific size

exiqgrep -s '^4..$' [...]

For example, 400-499 bytes. Use -z to match only frozen messages, or -x to match only unfrozen messages. To display just the message-id, use -I, while -c displays the message count.

Display the message count of the mail queue 

exiqgrep -c ...

Start a queue run

root@localhost# exim -q -v

Start a queue run isolated to local deliveries

root@localhost# exim -ql -v

Remove a message from the queue 

root@localhost# exim -Mrm <message-id> [ <message-id> ... ]

Freeze a message

root@localhost# exim -Mf <message-id> [ <message-id> ... ]

Throw a message

root@localhost# exim -Mt <message-id> [ <message-id> ... ]

Deliver a message

root@localhost# exim -M <message-id> [ <message-id> ... ]

Deliver a message (if the retry time has been reached) 

root@localhost# exim -Mc <message-id> [ <message-id> ... ]

Force a message to fail

root@localhost# exim -Mg <message-id> [ <message-id> ... ]

Remove all frozen messages

root@localhost# exiqgrep -z -i | xargs exim -Mrm

Remove all messages older than a defined number of seconds

root@localhost# exiqgrep -o seconds -i | xargs exim -Mrm

Freeze All Queued Mail from a Named Sender

root@localhost# exiqgrep -i -f luser@example.net| xargs exim -Mf

View a message’s mail headers

root@localhost# exim -Mvh <message-id>

View a message’s body

root@localhost# exim -Mvb <message-id>

View a message’s logs 

root@localhost# exim -Mvl <message-id> 

Add a recipient to a message

root@localhost# exim -Mar <message-id> <address> [ <address> ... ]

Edit a message sender

root@localhost# exim -Mes <message-id> <address>

 

about author

Sam

samatwwc@gmail.com

WebDeveloper, Php, MySQL, WordPress, Magento, cPanel, Plesk, WHM, WooCommerce

Leave a Reply

Your email address will not be published. Required fields are marked *