Re: get domain component from email
| From: | Richard Lynch | Date: | Tue, 07 Aug 2007 23:48:42 +0000 |
| Subject: | Re: get domain component from email | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-260356@lists.php.net to get a copy of this message | ||
On Tue, August 7, 2007 1:25 pm, Kevin Waterson wrote:
> Im looking for a way to get the domain from an email address.
> Not sub domains, just the domain, so
> luser@foo.bar.example.com.mn
> would return
> example.com.mn
>
> similarly, the address luser@example.com would return
> example.com
>
> perhaps an array of tld's, then strip the tld off the end and anything
> before that and the next "." is the domain?
>
> also, somebody told me .co.uk was a tld, but I cannot see it listed
> http://www.iana.org/root-whois/index.html
I think you're in trouble...
The "rules" for what is or isn't a TLD have changed over time.
I did see a nice article the other day in the RFCs about some
pragmatic ways to do this "right" without killing yourself, or coding
something that's bound to break within a very short time. Don't know
the RFC# offhand though, but I got the feeling that it was pretty
recent...
The LAST thing you want to do is hard-code the list of known TLDs from
today, because that will change too often.
.co.uk is a TLD, afaik...
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?