|
July 2004
Shell Corner: POP3 mail filtering and retrieval with bash
Hosted by Ed Schaefer
This month, Chris F.A. Johnson presents Bash script mfilter, which retrieves and deletes email from a POP3 mail server. Chris also presents a short tutorial on communicating with a POP3 server.
POP3 mail filtering and retrieval with bash
Last year, when the SWEN virus (more properly, the SWEN worm) struck, I found my computer slowing to a crawl. At first, I was receiving 10 to 15 "Cumulative Patch" messages a day. Then, the number suddenly jumped, and at its height I was getting more than 2,000 a day. At approximately 150,000 bytes each, that was a daily download of more than 300 MB.
Posters to Usenet newsgroups were especially targeted, so I started using a new email address in my posts — one that I had created just for this purpose. Within 3 hours of my first post from that address, it started receiving the worm's excrement.
My first attempt to foil it was with Mailfilter (http://mailfilter.sourceforge.net), a utility that deletes unwanted mail (defined by your rules) on a POP3 server without downloading entire messages.
Mailfilter had two drawbacks:
- It only examined the headers, and there was enough variation in those to make writing rules difficult. (William Park suggests that boundary="[a-z]+" will catch them all; he may be right, but it doesn't address the second problem.)
- The junk was arriving so thick and fast that often several messages would arrive between Mailfiter exiting and the downloading program connecting, and they would be downloaded.
|