This full static mirror of the Run Up to Date Linux Everywhere Project is kept online by Free Software popularizer, researcher and trainer Marco Fioretti. To know how you can support this archive, and Marco's work in general, please click here

POPFILTER: delete unwanted email on pop3 server instead of downloading it

On the Net there are a *lot* of examples on how to download automatically your email from different POP3 servers into your computer, and, once it’s there, how to process it, i.e. how to sort it, delete spam, send automatic answers, etc,etc.. However, I have always found a couple of flaws in these strategies for filtering email.

Why delete AFTER download?

While should I download a message, spending time and money, when I already know that I’m not interested in it? Even with permanent flat rate connections, why move stuff around just to delete it somewhere else? This is especially true with mailing lists: most of the threads are of little or no interest whatsoever to me, but they vary all the time, and I cannot certainly flag the mailing list address as spam.

For example, imagine a 100 messages thread going on for days about RAID, and you don’t use it at all. Why should you ever download the messages, then? If you change your mind next month, mailing lists are mirrored on the net anyways, right? (of course, when it’s mail that would not be backed up anywhere else it’s different..)

1.2 Filtering with procmail only is static

Another fault I’ve found in usual email filtering procedures is that they can’t be driven dynamically from the email client: everything is static, i.e. written once and for all in procmailrc, while I wanted to select a message from inside my mail client, and tell to it “let’s not download any reply to this”


I have written a short Perl script which should solve the two problems above: it doesn’t replace anything in the email chain (fetchmail/MTA/procmail), but it is supposed to run just before fetchmail. POPFILTER is an email utility that connects to the POP3 server, reading account info from fetchmailrc and then:

  • downloads only the headers of all messages
  • check if a message recipient (list) and subject are in the black list
  • if this is the case, sends a delete command to the POP3 server

After POPFILTER has finished, fetchmail can step in and download what’s left. Hopefully, it will be a much smaller amount of data.

Other similar programs

Some days after writing popfilter, it did come to my mind that I should have searched Freshmeat first. I did it, and found several existing programs doing the same thing. They are listed here, together with the reasons why I decided to keep using my script:

  • mailfilter (no auto reply, which I plan to add in the future)
  • animail (overlaps with fetchmail, which I wish to keep, and is written in Python: fine language, but I don’t have time to learn it now)
  • popsneaker (requires external libs, and is more than 2000 lines of code against the 179 of popfilter)

Furthermore, as already mentioned, I wanted something that I could drive at will from the email client. Of course, the ones above are all fine pieces of software, and you are encouraged to try them all.

Supported mail user agents

Any Mail User agent which can pipe the headers of a selected message into formail can work with POPFILTER.

Mutt macros

Insert the two macros included with POPFILTER in your .muttrc file and use them whenever you have highlighted a message whose follow-ups you don’t want to download anymore


Download the software here after installing the Perl MAIL::POP3Client module if you don’t have it already; put the scripts in /usr/local/bin with appropriate permissions and go.

TO DO list

  • Add a “ggod list” and a “bad list”, i.e. messages to never discard or always discard
  • Capability to combine rules

  • When receiving messages with Word attachments and/or in HTML format, automatically send polite but firm request to not indulge in such bad abits….


  • Sean Dowd <>,author of MAIL::POP3Client;
  • Advanced Perl Programming of Sriram Srinivarasan is where I first found mentioned something like this
  • There is a script somewhere on the Net which deletes mail on POP3 server but statically, i.e. it has a fixed list. The script name is checkmail.cmd, the author is not mentioned in the script.
  • Conor Daly and especially Aaron Schrab on the Mutt mailing list, which provided the mutt code above
  • The February 2001 issue of the Linux Gazette features an almost identical interaction between mutt and procmail, which makes filtering semi-dynamic, but still requires to download all messages.


I am very interested in making popfilter as robust and general purpose as possible. Any feedback (questions, patches, opinions, etc..) is welcome, please send me an email.

RULE = Run Up to Date Linux Everywhere
This entry was posted in Software. Bookmark the permalink.