At 18:55 2005-04-08 -0700, multimedia-fan(_at_)myrealbox(_dot_)com wrote:
How do you extract the top level domain name from the sender's email
address?
For example
From: "Firstname Lastname" <username(_at_)subdomain(_dot_)address(_dot_)com>
I would like to match the address.com info a variable.
Er, keep in mind that TLDs are not limited to just the two Right-Hand most
tokens - ISO based national TLDs may be two or three, and there's no
telling when: demon.co.uk, or somedumbshow.tv
You might look to use 'host' (a DNS tool, external from procmail) in some
fashion. For instance:
host -t SOA host.domain.tld
If it returns null, then you're probably at a host level specification, and
should trim one more token off the LHS and try again. You could issue a
command like so:
host -v host.domain.tld
and grab the first line beyond ";; AUTHORITY SECTION" (which may be a tag
specific to your implementation of 'host'). That'd be one query operation,
and you could parse the TLD from there (presuming that the host itself is
valid).
Either way, I could see a problem with a delegated subdomain (such as a
large corporation or university might have - engineering.someuniverity.edu
and polysci.someuniversity.edut might be wholly delegated from
someuniversity.edu, so their logical "TLD" in this respect is their
respective subdomain).
---
Sean B. Straw / Professional Software Engineering
Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
Please DO NOT carbon me on list replies. I'll get my copy from the list.
____________________________________________________________
procmail mailing list Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail