could i get some help with nslookup plz

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sansoo
Forum Commoner
Posts: 32
Joined: Mon Aug 14, 2006 5:33 pm
Location: Smallville

could i get some help with nslookup plz

Post by sansoo »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Sorry for being such a newb and asking a seemingly easy question but hey i cant figure this thing out.
Ive gone to lots of freaking tutorials and most of them assume a hight level of PHP knowledge than i currently possess.

anyways im using nslookup.exe in of course an email verification.  The code for that function is as follows

Code: Select all

function Email ($Email) {
$Email = $_POST['Email'];
list($userName, $mailDomain) = split("@", $Email);
$false = "Invalid Email Address";
if(!empty($userName)) {
	if( $mailDomain == '' ) $mailDomain = "MX";
   	exec('nslookup.exe -type=mx ' .$mailDomain, $result);
   // check each line to find the one that starts with the host
   // name. If it exists then the function succeeded.
   	foreach ($result as $line) {
     	if(eregi("^$mailDomain",$line)) {
			if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $Email)) {
			return $Email;
			}
		}
}return $false;
}return $false;
}
My question is first is this thing, monster, i created a bad hack job at PHP or Is it ok or does it need improvement?
And it appears that this function is returning TRUE anything that has a hostname that is a real site.
example-> "sansoo@hotmil.com" returned TRUE
hotmil.com is a parked domain name.
THis i dont understand because i have been to other sights and they were somehow able to see that i had miss typed my email address and it didnt pass. With my function you can type in anything that there is a registered TLD for.

I dont get it and i need some help either fixing this function or scrapping it and doing something better


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
bokehman
Forum Regular
Posts: 509
Joined: Wed May 11, 2005 2:33 am
Location: Alicante (Spain)

Post by bokehman »

Your function is a waste of time and resources. All it does is check a domain has an MX record. First, an MX record is not necessary for receiving mail and second, just because a domain has an MX record doesn't prove anything about a particular email address.
sansoo
Forum Commoner
Posts: 32
Joined: Mon Aug 14, 2006 5:33 pm
Location: Smallville

Post by sansoo »

thanks

thats what i wanted to know. And thats what i figured the deal was. Couuld you point me the direction of what i need to do to validate an email address is current and active?

all the searching i did yesterday kept turning up tutorials on doing an "MX" look-up.

For the service i will be providing on the site it is imparitive that i validate email addresses as best as i can.

I know the alternative is to send an email to the address provided with a link to activate the account in it. But i have personally tried to join some communitees in the past where i never recieved an email. Possibly do to an error on my part or a server error on their side.

Trying to make this validation as client friendly as possible.

thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

sansoo wrote:thats what i wanted to know. And thats what i figured the deal was. Couuld you point me the direction of what i need to do to validate an email address is current and active?
Outside of emailing them and waiting for a bounce from the server.. there's little else.

Many servers these days, due partly to spammers, will deny the existance of any email address when queried.

One thing you could possibly do is allow them to enter several email addresses. The one that works is the one kept. There are some other ideas, but that's probably the most straight forward.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

But i have personally tried to join some communitees in the past where i never recieved an email.
Probably got blocked by a spam filter, for example, SpamAssassin for me blocks Digg's registration emails.

I recommend you give users instructions on how to whitelist the registration email sender address.
sansoo
Forum Commoner
Posts: 32
Joined: Mon Aug 14, 2006 5:33 pm
Location: Smallville

Post by sansoo »

Thanks for the help.

I think i like a combination of both ideas. I will probably opt for a sign-up like most forums do and send a confirmation email that holds there account on stand-by until responded too.

I will however have to include a how-to whitelist my site email area within the registration.

If only spam and splogs had never been invented the rollercoaster we call the world wide web we be such a smoother ride.

CONSIDER THIS PUPPY CLOSED...plz mark as such cuz i feel dumb for starting this abomination in the first place

EDIT-> Before this is marked as solved would it be sufficent to include a "how-to whitelist" for Hotmail, Yahoo, and AOL only?
Or should it just be a general how-to?
User avatar
bokehman
Forum Regular
Posts: 509
Joined: Wed May 11, 2005 2:33 am
Location: Alicante (Spain)

Post by bokehman »

sansoo wrote:it is imparitive that i validate email addresses as best as i can.
Send them an email that contains a unique link that identifies them as part of the registration process.
Post Reply