November 2nd, 2000, 10:38 AM
I want to validate the domain name of an email address in my scripts to see if the domain exists.
To make it easier I just want to check the TLD and the 2nd LD (e.g. devshed.com).
Anyone any ideas on how to tackle this challenge?
November 2nd, 2000, 07:49 PM
To validate whether an email address is in proper format is NOT the same as to validate whether the domain part of an email actually exist.
To validate the email format, just click the search link on this page as it has been discussed dozen times.
As for the other case, you need launch an external program/command to determine the existence of that domain. i.e. nslookup.
November 2nd, 2000, 09:58 PM
Look under Network Functions in the PHP Manual. There are some functions for getting IP addreses from Host names. You might be able to do something like this:
$ip = gethostbyip("devshed.com");
If it returns an IP address, you can assume the hostname is valid...That example might not work exactly, I can't remember the name of the function exactly.