Quick way to remove all frozen emails from mail queue Exim

An introduction layer to Frozen mails

Simply, frozen emails are the emails sent to invalid, non existing email accounts that were undelivered to the address correctly.

If the email can’t be delivered to an account, the email will be added in the queue and Exim will try a couple of times to deliver the email as per the settings in the RETRY CONFIGURATION in Exim conf file.

If the email didn’t deliver to the recipient after the predefined days in Exim conf (timeout_frozen_after), those emails will be marked as frozen.

# grep timeout_frozen_after /etc/exim.conf

timeout_frozen_after = 5d

The exim mail server has a lot of command line options to manage email queue. Refer this topic for How to check spamming on server which has Exim as MTA.

How to remove all frozen emails from the mail queue?

Here we goes! You can remove the frozen mails by executing different combinations of Exim commands.

Method I

By using ‘exim -bp‘ command

# exim -bp|grep frozen|awk '{print $3}' |xargs exim -Mrm

Method II

By using ‘exiqgrep‘ command

# exiqgrep -iz|xargs exim -Mrm

Cool 🙂


1, How to check spamming on server which has Exim as MTA
2, Exim Log line flags
3, Exim command to find the mail that we have sent is completed or not(Unix/Linux)

Post navigation

Arunlal Ashok

DevOps Engineer at Zeta Suite. Linux lover. Traveller. Father of two princesses.

Always happy for an open discussion! Write to arun ((@)) crybit ((dot)) com.
LinkedIn: https://www.linkedin.com/in/arunlal-a-18037773/

8 thoughts on “Quick way to remove all frozen emails from mail queue Exim

  1. I am using MailEnable Mail server which provide best Spam Email server software. It provides best secure email software.

  2. I suggest never user # exim -bp|grep frozen|awk ‘{print $3}’ |xargs exim -Mrm for removing frozen mails. Because if email address contains frozen word then that mail also will get removed. And that email might be genuine mail also.
    For example if email address is [email protected], and this caries a genuine, then this mail will also get removed.

    So # exiqgrep -iz|xargs exim -Mrm is best and safer side.

  3. Might interest readers of this thread.
    Takes all the frozen mails and put them in a new mailbox, then deletes the frozen msgs. It might benefit from the @Shashank wrt exiqgrep fix: (BTW the date format is the real pain)

    # bash /usr/local/bin/thawmail.sh > /tmp/old-frozen.mbox
    The entire message queue (before)
    exim: no message ids given after -Mrm option
    The remaining message queue (after)

    # ls -l /tmp/old-frozen.mbox
    -rw-r–r– 1 root root 0 Jan 12 16:12 /tmp/old-frozen.mbox

    # cat /tmp/old-frozen.mbox

    # cat /usr/local/bin/thawmail.sh
    #!/bin/bash -ue
    # Take all the frozen messages off the queue and dump them to stdout
    # So Ideally you use it like:
    # thawmail > 12jan2021.frozen.mbox
    echo “The entire message queue (before)” >&2
    exim -bp >&2

    # Dump all the frozen messages
    #exim -bp | grep frozen | awk ‘{print $3}’ |xargs -L1 -I % echo ‘echo -e “\nFrom [email protected] Mon Jan 3 10:18:01 2022 +0000” ; exim -Mvc %’ | bash
    #exim -bp | grep frozen | awk ‘{print $3}’ |xargs -L1 -I % echo ‘echo -e “\nFrom [email protected] $(date -R)” ; exim -Mvc %’ | bash
    exim -bp | grep frozen | awk ‘{print $3}’ |xargs -L1 -I {} echo ‘echo -e “\nFrom [email protected] $(date +%a\ %b\ %d\ %T\ %Y\ %z)” ; exim -Mvc {}’ | bash

    # Delete all frozen mails (slight race here, can’t be helped)
    exim -bp | grep frozen | awk ‘{print $3}’ | xargs -L1 exim -Mrm

    echo “The remaining message queue (after)” >&2
    exim -bp >&2

Leave a Reply

Your email address will not be published.