Important Exim commands & Cheat sheet to manage your Email Queues via Secure Shell

Exim is an open source mail transfer agent (MTA), used in Linux based OS & is an email program that is responsible for receiving, routing, and delivering e-mail messages (this type of program is sometimes referred to as an Internet mailer, or a mail server program). It is not an exchange server, but a mail agent within the server to handle emails. Exim is a message transfer agent (MTA) developed at the University of Cambridge for use on Unix systems connected to the Internet. Below are some of the commands that is used to manage email queues using Exim.
Command to show number of emails in exim queue.
Command: exim -bpc [~]# exim -bpc

Command to show all emails in the queue:
Command: exim -bp [~]# exim -bp
14h   906 1drVos-0001JR-W9 <>

10h   31K 1drZWv-0003dp-8q <>
exim -bp shows all emails in the queue with age, mail size, pool file id, from & to addresses.
Command to find Exim Queue Summary:
Command: exim -bp | exiqsumm
user@server1 [~]# exim -bp | exiqsumm

Count  Volume  Oldest  Newest  Domain
-----  ------  ------  ------  ------

    2    1812     14h     14h
    1    31KB     11h     11h
    3    33KB     14h     11h  TOTAL
This command provides summary of whole email queue of the server including, email count, email size, age & domain with emails per domain name.
Command to read email header using Exim via shell:
exim -Mvh exim-id
(replace exim-id with the original exim id of the queue from command exim -bp)
Command to read email body using Exim via shell:
exim -Mvb exim-id
(replace exim-id with the original exim id of the queue from command exim -bp)
Note: -Mvb - message view body -Mvh - message view header.
Command to remove an email using Exim via shell:
exim -Mrm exim-id
(replace exim-id with the original exim id of the queue from command exim -bp)
Note: -Mrm -message remove.
Remove multiple emails from queue:
First we need to look at a pattern/regex to remove emails or domain name, then we append other shell commands to remove emails. Example: Remove all emails from user, the command would be:
exim -bp | grep "" | awk '{print $3}' | xargs -i exim -Mrm {}

The above command will grep all emails in the queue of user then awks row three which is message id & then sends to removal. Please do use this command carefully & *Do Not* copy paste.
Remove all emails from exim email queue:
We use exiqgrep command to handle most of email queue related tasks rather that exim direct command. To remove emails, we run:
exiqgrep -i | xargs -i exim -Mrm {} 

This will grep all ids of exim email queues & append to removal.
exiqgrep command & usage: exiqgrep is a program & an Exim message queue display utility tool used to manage your email queues via shell interface. You can collect any details of exim queue using this powerful tool & the usage is as below: Exim message queue display utility.
Usage: exiqgrep -option input
exiqgrep -
        -C              Specify which exim.conf to use.

Selection criteria:
        -f      Match sender address sender (field is "< >" wrapped)
        -r      Match recipient address
        -s      Match against the size field from long output
        -y     Message younger than
        -o     Message older than
        -z              Frozen messages only (exclude non-frozen)
        -x              Non-frozen messages only (exclude frozen)

[ NB: for regexps, provided string sits in // ]

Display options:
        -c              Display match count
        -l              Long Format [Default]
        -i              Message IDs only
        -b              Brief Format
        -R              Reverse order
        -a              All recipients (including delivered)
  • exim, vps, email, queue, delete emails
  • 2 Users Found This Useful
Was this answer helpful?

Related Articles

How to enable the html display for horde webmail?

This step is only for VPS managed severs and cpanel/whm setup. Log into server via shell:vi...

Best way to fight & prevent email spamming on your server

This article provides instruction on prevening email spamming from your hosting account or from...

Understanding Email Services

MUA: Mail User Agent (email client): The MUA is the front-end for the end user to manage and read...

Understanding POP, IMAP, Dovecot

Dovecot is an open source IMAP and POP3 email server for Linux/UNIX-like systems, written with...

Installing Exim on Cent OS 6.x / 7.x

Operating System: Cent os 6.x / 7.xHostname: hostname [not a registered domain name, but you can...

Powered by WHMCompleteSolution