Can't delete emails from Exim queue

Digital Essence

Verified User
Joined
Jan 9, 2023
Messages
21
Hi,

last week I had an issue with the recent version of Exim 4.97 changing the Message ID format and this messed up MailScanner leaving me with emails in the exim queue that weren't delivered and now can't be deleted.

I'm now trying to clear my Exim queue but when I try and delete emails they won't delete and I just get this repsonse:

Example Message ID: 1r1U5o-00000000Bo3-2OLC

exim -Mrm 1r1U5o-00000000Bo3-2OLC
Spool data file for 1r1U5o-00000000Bo3-2OLC does not exist
Continuing, to ensure all files removed
Spool read error for 1r1U5o-00000000Bo3-2OLC-H: No such file or directory
Continuing to ensure all files removed
Message 1r1U5o-00000000Bo3-2OLC has been removed or did not exist

If I now do an exim -bp, the same message is still in the queue. How do I clear these "corrupted" messages out of the queue?

Thanks.
 
I hope Mailscanner isn't blocking the removal.

You could just try the admin mailqueu administration.

If you already did that, try Configserver mailqueue, it's free too:

If that won't help, try locating them physically below the /var/spool/exim/input directory. However, you might need the find command as this directory contains loads of directory's too.

Or try not do delete by message id but by sender or receiver.

I've got this script I once got from somebody or found on the net, working perfectly. My empty-exim.sh file:
Code:
#!/bin/sh
if [ $1 ]; then
echo "`exim -bpru | tr '\n' + | sed -e "s/++/=/g" | tr -d + | tr = '\n' | grep "$1" | awk {'print $3'} | xargs exim -Mrm | wc -l` E-Mails deleted"
else
echo "If you want to delete ALL the `exim -bpc` E-Mails on mail queue, give this command:"
echo "exim -bp|grep "<"|awk {'print $3'}|xargs exim -Mrm"
echo "or even better"
echo "exim -bp | awk '/^ *[0-9]+[mhd]/{print "exim -Mrm " $3}' | bash"
echo ""
echo "If you want to delete only mails with an specific sender/recipient, use:"
echo "$0 [sender/recipient]"
fi
Save in .sh file and chmod to 755.

Now you can also remove by using for example ./empty-exim.sh @receiverdomain.com to remove mails.
Just use ./empty-exim.sh to see the options on how to use (for anyone interested).
 
Last edited:
Thanks Richard.

I'm also hoping MailScanner isn't blocking their removal.

I'd already tried the DA queue tool and the CSF tool and both failed to remove the emails. I've now given your script a bash but it's failing. Option 1 gave me:
Bash:
exim -bpru | awk {'print '} | xargs exim -Mrm
exim: malformed message id 3d after -Mrm option


and option 2:

Code:
exim -bp | awk '/^ *[0-9]+[mhd]/{print exim -Mrm  }' | bash

gives me loads of command not found.

When I use ./empty-exim.sh [email protected] it tells me it has deleted X emails but when I check, the queue is exactly the same length as it was previously

I have seen a fairly brutal:

Code:
service exim stop
rm -fvr /var/spool/exim/input
service exim restart

which might be my next option.
 
gives me loads of command not found.
Yes the script is a bit old, I mostly use just part of the mail address like @sender.tld or sender.tld don't remember exactly but it's always working.

I have seen a fairly brutal:
Yes well... I've seen a kindlike but a bit more safe because it creates a backup first, in a post of 2006 here on the forums.

Code:
cd /var/spool
mv exim exim.old
mkdir -p exim/input
mkdir -p exim/msglog
mkdir -p exim/db
chown -R mail:mail exim
/sbin/service exim restart

If everything works oke after this, you can remove the exim.old backup directory.
 
exim -bpru | awk {'print '} | xargs exim -Mrm
exim: malformed message id 3d after -Mrm option
Got the same error so I adjusted that part of the suggestion in the script and edited my post to correct it to a working alternative.
Second line I have to search for a better solution, indeed not working anymore, but that's something for another time.
 
Thanks Richard.

I'm also hoping MailScanner isn't blocking their removal.

I'd already tried the DA queue tool and the CSF tool and both failed to remove the emails. I've now given your script a bash but it's failing. Option 1 gave me:
Bash:
exim -bpru | awk {'print '} | xargs exim -Mrm
exim: malformed message id 3d after -Mrm option


and option 2:

Code:
exim -bp | awk '/^ *[0-9]+[mhd]/{print exim -Mrm  }' | bash

gives me loads of command not found.

When I use ./empty-exim.sh [email protected] it tells me it has deleted X emails but when I check, the queue is exactly the same length as it was previously

I have seen a fairly brutal:

Code:
service exim stop
rm -fvr /var/spool/exim/input
service exim restart

which might be my next option.
do u fix it ??
 
do u fix it ??
Solved here :
 
Back
Top