Qmail mailRemove.py



    This python script is a simple tool to remove email from a Qmail mail queue that has a certain pattern of text within it. It was designed to be fast and non-destructive. I built this script when I was working at eGroups.
    All you need is Python, and most Linux systems or Unix systems in general use that.


    Stability/Bugs
    This program has been used by thousands of people since December 1999. There have been only 2 or 3 bugs, and those were not destructive. I consider the program very stable.

    Revisions
    2003/02/07 - I got a small patch from Michiel van Wessem for handling bounce directory.


    Download it here:

    mailRemove.py

    restore.py - - This was needed by a user in Peru. It will restore filtered mail back into the Queue.


    How To Use
    • Download the script. Insure that you have the proper path to python in the script. Currently, it is set to '#!/usr/bin/python' (where RedHat installs it), you may need to change that to '#!/usr/local/bin/python' if that is where you have it. Be sure to do a 'chmod +x ./mailRemove.py' on the script so that unix will execute it.
    • Become a privileged user. Become root or whatever user you need to be to manipulate the queue files.
    • Stop qmail. Any program that works on the qmail queue's will need to do this. qmail cannot deal with programs manipulating the queue while it is running.
    • Create a /var/qmail/queue/filter directory. This is where the filtered email will go.
    • Run the script as a test run.
      For example, this would scan for emails that had the words 'annacsfun' or 'puyals98' in ANY part of the emails.
      ./mailRemove.py annacsfun puyals98
      

    • Run the script, FOR REAL,
      ./mailRemove.py --real annacsfun puyals98
      

    • Start qmail again. You are done.