0

How do I remove emails from mqueue based on destination address. Needing to remove deferred messages going to "[email protected]"

Due to an endless loop (that has been found and corrected) I have a huge amount of emails deferred or qued for retry in var/spool/mqueue. Need to clear these out ASAP as the bounceback messages are filling up my var/log folder space by 1G every 20min.

There is legit email also in the que so can't just empty var/spool/mqueue. How do I filter to just the results I am looking for? And, do I need to stop sendmail first?

Results from df -h in mqueue showing /dev/sda2 filesystem 100% used due to var/log

root@tsunami12:/var/log# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev             32G     0   32G   0% /dev
tmpfs           6.3G  650M  5.7G  11% /run
/dev/sda2        28G   28G    0G 100% /
tmpfs            32G     0   32G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs            32G     0   32G   0% /sys/fs/cgroup
/dev/sda4       2.1T  986G 1013G  50% /home
tmpfs           6.3G     0  6.3G   0% /run/user/1000
tmpfs           6.3G     0  6.3G   0% /run/user/1002
tmpfs           6.3G     0  6.3G   0% /run/user/1003

Results from ls -lh in mqueue

root@tsunami12:/var/spool/mqueue# 
ls -lh

-rw-r----- 1 smmta smmsp    0 Mar 17  2020 df02H2TsFs012156
-rw-r----- 1 root  smmsp 2.8K Apr 14 10:17 df33EDseEV018975
-rw-r----- 1 root  smmsp 3.6K Apr 14 10:12 df33EECwjo001842
-rw-r----- 1 root  smmsp 2.3K Apr 14 10:43 df33EEhHEt023903
-rw-r----- 1 root  smmsp 2.3K Apr 14 10:45 df33EEj5ai025020

Results from mailq command

33J38Htu005703     3623 Tue Apr 18 23:08 <[email protected]>
                  (Deferred)
                                          <[email protected]>
                                          <[email protected]>
                                          <[email protected]>
                                          <[email protected]>
                                          <[email protected]>
33J382mj005213     3623 Tue Apr 18 23:08 <[email protected]>
                 (Deferred)
                                         <[email protected]>
                                         <[email protected]>
                                         <[email protected]>
                                         <[email protected]>
                                         <[email protected]>

Results from root@tsunami12:/var/log# tail mail.log command

Apr 19 15:54:56 tsunami12 sm-mta[22495]: 33INJGL5000565: to=<[email protected]>,<[email protected]>,<[email protected]>,<[email protected]>, delay=20:35:40, xdelay=00:00:00, mailer=esmtp, pri=10924132, relay=smtpin01.vzw.a.cloudfilter.net., dsn=4.0.0, stat=Deferred: Connection reset by smtpin01.vzw.a.cloudfilter.net.
Apr 19 15:54:56 tsunami12 sm-mta[15318]: 33J0R2EH028306: to=<[email protected]>,<[email protected]>, delay=19:27:53, xdelay=00:00:00, mailer=esmtp, pri=10655014, relay=att-e2xms-west.mx.a.cloudfilter.net., dsn=4.0.0, stat=Deferred: Connection reset by att-e2xms-west.mx.a.cloudfilter.net.
Apr 19 15:54:56 tsunami12 sm-mta[15318]: 33J0R2EH028306: to=<[email protected]>, delay=19:27:53, xdelay=00:00:00, mailer=esmtp, pri=10655014, relay=tmo-east.mx.a.cloudfilter.net., dsn=4.0.0, stat=Deferred: Connection reset by tmo-east.mx.a.cloudfilter.net.
Apr 19 15:54:56 tsunami12 sm-mta[15318]: 33J0R2EH028306: to=<[email protected]>,<[email protected]>,<[email protected]>,<[email protected]>, delay=19:27:53, xdelay=00:00:00, mailer=esmtp, pri=10655014, relay=smtpin01.vzw.a.cloudfilter.net., dsn=4.0.0, stat=Deferred: Connection reset by smtpin01.vzw.a.cloudfilter.net.
Sarah
  • 1
  • 1

1 Answers1

0

From memory I recall there are df* files and corresponding qf* files but since I don't run sendmail here I can't guarantee that. You should find that one acceptable approach is to remove files from /var/spool/mqueue that contain the text [email protected]. Not perfect but very close.

cd /var/spool/mqueue
mkdir /var/spool/mq.rm
mv $(grep -l '[email protected]' *) ../mq.rm

You should now have a much shortened mail queue and the messages pending deletion in the directory /var/spool/mq.rm.

As always test thoroughly before applying to your live environment

roaima
  • 107,089
  • 14
  • 139
  • 261