remove similar mails from mailqueue

Discussion in 'Help Desk' started by DearWebby, Apr 23, 2015.

  1. DearWebby

    DearWebby Greylisted

    Apr 23, 2015
    Likes Received:
    How can I delete a big bunch of mails from the mailqueue without hunting each ones two files down with locate and manually delete them?
    Is there a command for that?
    Or has somebody ever written a bash script for that, that takes for example the FROM address and dumps all mails with that FROM address from the queue?
    I hope whoever comes up with a bash script for that can accept PayPal!

  2. popowich

    popowich EQ Forum Admin Staff Member

    Aug 12, 2008
    Likes Received:

    Here is the example for Postfix in case anyone looking for a solution for that MTA lands here:

    I found this example for sendmail but did not test it yet:

    > find /var/spool/mqueue -name "[d,q,Q,D]f*" -exec grep -nil "" {} \; | xargs rm

    It needs to be adjusted to match your queue directory and the email address of the sender of you want removed from the queue.

    If this happens to be a lot of spam on a web server I'd also check your web sites for compromised web forms and/or WordPress plugins being used to send spam.

Want to reply or ask your own question?

It only takes a minute to sign up (and it's free!). Click the orange sign up button to choose a username and then you can ask your own questions on the forum.