Unix Review > Archives > 2004 > May 2004

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:
  1. 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.)
  2. 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.

Sys Admin Spotlight

CMP DevNet Spotlight

Regular Expressions: Two Easy Steps Better Than One Hard One
Complicated regular expressions and yacc are powerful parsing tools, but they can cause trouble in inexperienced hands. One helpful alternative is "partial evaluation" (PE) or "active data" parsing

In the News

CD-ROM

Sys Admin and The Perl Journal CD-ROM version 11.0

Version 11.0 delivers every issue of Sys Admin from 1992 through 2005 and every issue of The Perl Journal from 1996-2002 in one convenient CD-ROM!

Order now!




MarketPlace

Build IT Knowledge with Current & Trusted Content
Helps Employees Develop & Hone New Technical Programming Skills. Sign Up & Get Full Access.

Six Sigma Certification
100% Online-Six Sigma Certificate from Villanova - Find Out More Now.

Discover WinDev 11 RAD
and develop 10 times faster ! ALM, IDE, .Net, PDF, 5GL, Database, 64-bit, etc. Free Express version

Domain Name Registrations, Web Hosting, Email
Pay less for Domain Names, Increase your company's bottom line - get a raise. Accredited domain name registrar, ZippyNames.us : Discount bulk transfers, email, webhosting, dedicated servers. Earn money as a domain name reseller - better discounts!

Wanna see your ad here?