From Adrian Lattke on 28 Apr 1998
I must conratulate you. I found your page on "Procmail Mini-Tutorial: Automated Mail Handling" extremely useful. You see, I was browsing the web in search for a program that will filter Mailer Daemon bouncebacks. Would you happen to know, if there is any way, from a perl script, to determine if an email address is valid? Or, how exactly should I configure procmail and its files to filter daemons into a directory? What I want to say is, do you know of any program with a set of rules for identifying a bounceback, and extracting the address that it bounced from, appending it to a file?
Thank you very much for your help,
There is no way to determine if an address is "valid" in the sense that it really leads to someone's inbox, other than sending them mail and getting a response. Anything else is only a guess. (Technically that's "verification" rather than "validation" -- but the terms are often interchanged and misused).
In the more precise sense it is possible to validate a string as complying with RFC 822. That's the IETF document that defines the proper formatting and structure of Internet e-mail headers and addresses. However this is not a trivial task. (I think Tom Christiansen mentioned that it took him a hundred ugly lines of perl code to do it). You might look at CPAN (the Comprehensive Perl Archive Network --- a set of co-operating mirror sites that forms the canonical repository of publicly available perl sources libraries and modules). Look at http:/www.perl.org/ for starters.
As I said, procmail does handle many of these details for you --- which is why I use it. I figure Stephen R. van den Berg (procmail's author) knows alot more about RFC822 parsing than I want to.
Regarding your desire to automatically extract and record addresses that result in bounce messages (responses from MAILER-DAEMON):
I'd suggest that you grab a copy of SmartList (the automated mailing list management package that's built over procmail, and is by the same author). That has the best "bounce handling" features that are available among the Majordomo, ListServ, ListProc set (from what I hear on the list-managers mailing list at GreatCircle.com). So, you could grab it and look through its procmail sources to find out how it handles the automated removal of "dead" addresses from its subscriber lists. That's got to be pretty close to what you've described.