LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   delete all mail with exactly same subject from postfix queue (https://www.linuxquestions.org/questions/linux-server-73/delete-all-mail-with-exactly-same-subject-from-postfix-queue-674980/)

badboynick21 10-08-2008 02:05 AM

delete all mail with exactly same subject from postfix queue
 
Is there any script to do such thing like we can delete all mails with exactly one recipient...

Mr. C. 10-08-2008 02:47 AM

Which do you want the mail Subject header as stated in this thread's subject, or mail recipient as stated in the post?

badboynick21 10-08-2008 04:15 AM

mail Subject header ...

Mr. C. 10-08-2008 04:53 AM

This is not a good idea on a live system; there is no programmatic interface for you to use to access the postfix queue while postfix is running. You can stop Postfix, and then use postsuper to delete all offending messages.

...but the idea is here:

Code:

# change directory to postfix's queue directory
cd $(postconf -h queue_directory)/active
# loop over queue files
for i in * ; do
  # postcat e file, grep for subject "test" and if found
  # run postsuper -d to delete queue'd message
  postcat $i |grep -q '^Subject: test' && echo postsuper -d $i
done

You can do similar for the hold and deferred directories, in a loop if desired. Remove the echo above to actually delete - currently the script only outputs what it would do.

Let me guess - is your queue filled up with backscatter for invalid recipients and your server is not doing recipient validation?

badboynick21 10-08-2008 05:12 AM

no my mailman's is sending pending password reminder request of last two year so i just want to delete those mails from the queue and clear all the pending mails on mailing lists.


All times are GMT -5. The time now is 09:32 PM.