Jump to content

Recommended Posts

hello,

          i am very much confused with smtp email validation. i just want to know that what it actually does? i mean it only checks the yahoo.com in karan23424@yahoo.com or it check the existance of e-mail address in the database.

please let me know if anybody knows about it and if possible please send me the smtp e-mail validation script , i have already tried a lot of scripts from net but all went in vain.

 

currently i have script that checks the server name properly but does not checks the existance of email.

 

eg:- if i use  the karan23424@yahoo.com email for testing

        the script says its valid email.

    but when i use sddfd@yahoo.com for testing, then it also says that it is valid email address. it means it checks only yahoo.com in the email address

 

Thanks for reading this problem

Link to comment
https://forums.phpfreaks.com/topic/157861-solved-smtp-email-validation/
Share on other sites

Not true, you can try to validate a user's account, if that account exists at that domain. Most of the time it won't reply but it can be done. karan23424, I guess are you asking for help with validating the string of an email or actually testing a server to see if that email account exists. It all depends on what your trying to do with your application.

Not true, you can try to validate a user's account, if that account exists at that domain. Most of the time it won't reply but it can be done. karan23424, I guess are you asking for help with validating the string of an email or actually testing a server to see if that email account exists. It all depends on what your trying to do with your application.

 

I assume she's not working Yahoo....

 

=)

So are you asking for something to check if an email is of valid format or if the email address actually exists? There's not really a way to check if an email address is real. I can have a domain and put "asdionwegkw@mydomain.com". The domain exists but that account doesn't. There's not really a way to check. And it's impossible to check if the user actually receives the email.

So are you asking for something to check if an email is of valid format or if the email address actually exists? There's not really a way to check if an email address is real. I can have a domain and put "asdionwegkw@mydomain.com". The domain exists but that account doesn't. There's not really a way to check. And it's impossible to check if the user actually receives the email.

 

Right.

 

Her/His best bet is to provide a registration link for the newly signed up individual to validate.....

 

If after say 36 hours, you don't click on it, the account is invalid or gets deleted...whatever...

 

 

Of couse you can check if its real!!

 

can you check if its used by the person whos entered it.. no (well only via an activation link or that sort of thing)

 

okay let get down to business

 

First whats the problem you say you have already tried a lot of scripts from net but all went in vain,

 

what are you trying to do ?

 

To check if a email is "Real" you need to get the email address and checks its valid but doing the following (in order)

[*]Its a Valid Email address format

[*]The domain exists

[*]get the MX (mail exchange) for the domain

[*]if theirs more than one MX then check each in priorities order

[*]if all MX fail attempt to use the domain

[*]Pass the email address to the Mail Exchange and see if the address is accepted as valid on that domain

 

So for example (use a simple regex ie basic example '%\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b%i')

A = madtechie@notmydomain

B = madtechie@notmydomain.com

C = NOTmadtechie@mydomain.com

D = madtechie@mydomain.com

 

1. Its a Valid Email address format?

A = False

B = True

C = True

D = True

So A has Failed it won't be tested anymore

 

2. The domain exists (ie ping the domain) sockets are fine here

B = false

C = True

D = True

So B has Failed it won't be tested anymore

 

-. get the MX (mail exchange) for the domain  (use getmxrr() or for windows Net_DNS_Resolver class)

(were say only 1 MX exists and its mail.mydomain.com)

 

3. Pass the C & D email address to the mail.mydomain.com and see if the address is accepted as valid on that domain. (again sockets)

open socket mail.mydomain.com:25

send ("HELO mydomain.com")

C = send("MAIL FROM: <NOTmadtechie@mydomain.com@mydomain.com>");

D = send("MAIL FROM: <madtechie@mydomain.com@mydomain.com>");

 

C = send("RCPT TO: <NOTmadtechie@mydomain.com@mydomain.com>");

D = send("RCPT TO: <madtechie@mydomain.com@mydomain.com>");

 

Return

C = code (not 250) No valid mailbox

D = code(250) Valid Mailbox

 

So C has Failed it won't be tested anymore

 

Okay so only D passed all thus its a valid email

 

So send an email to that email address with a activation link when thats url is used its done :D

 

EDIT:

LOL took me a while to type so missed a few replies

Of couse you can check if its real!!

 

can you check if its used by the person whos entered it.. no (well only via an activation link or that sort of thing)

 

okay let get down to business

 

First whats the problem you say you have already tried a lot of scripts from net but all went in vain,

 

what are you trying to do ?

 

To check if a email is "Real" you need to get the email address and checks its valid but doing the following (in order)

[*]Its a Valid Email address format

[*]The domain exists

[*]get the MX (mail exchange) for the domain

[*]if theirs more than one MX then check each in priorities order

[*]if all MX fail attempt to use the domain

[*]Pass the email address to the Mail Exchange and see if the address is accepted as valid on that domain

 

So for example (use a simple regex ie basic example '%\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b%i')

A = madtechie@notmydomain

B = madtechie@notmydomain.com

C = NOTmadtechie@mydomain.com

D = madtechie@mydomain.com

 

1. Its a Valid Email address format?

A = False

B = True

C = True

D = True

So A has Failed it won't be tested anymore

 

2. The domain exists (ie ping the domain) sockets are fine here

B = false

C = True

D = True

So B has Failed it won't be tested anymore

 

-. get the MX (mail exchange) for the domain  (use getmxrr() or for windows Net_DNS_Resolver class)

(were say only 1 MX exists and its mail.mydomain.com)

 

3. Pass the C & D email address to the mail.mydomain.com and see if the address is accepted as valid on that domain. (again sockets)

open socket mail.mydomain.com:25

send ("HELO mydomain.com")

C = send("MAIL FROM: <NOTmadtechie@mydomain.com@mydomain.com>");

D = send("MAIL FROM: <madtechie@mydomain.com@mydomain.com>");

 

C = send("RCPT TO: <NOTmadtechie@mydomain.com@mydomain.com>");

D = send("RCPT TO: <madtechie@mydomain.com@mydomain.com>");

 

Return

C = code (not 250) No valid mailbox

D = code(250) Valid Mailbox

 

So C has Failed it won't be tested anymore

 

Okay so only D passed all thus its a valid email

 

So send an email to that email address with a activation link when thats url is used its done :D

 

 

WOW.......

 

I am speechless.....I really thought there was no way.....

 

 

I do think though that sending an email with validation link is better for one thing only...

 

The user MUST accept the link and click on it. Otherwise, if she assumes the email is valid and creates the account, anyone can create an account for someone else like the President...

 

 

 

 

Do all domain use mail.mydomain.com?

 

No thats why we use a MX lookup, as allworknoplay said

 

getmxrr

(PHP 4, PHP 5)

 

getmxrr — Get MX records corresponding to a given Internet host name

Description

bool getmxrr ( string $hostname , array &$mxhosts [, array &$weight ] )

 

Searches DNS for MX records corresponding to hostname .

in my example i said

-. get the MX (mail exchange) for the domain  (use getmxrr() or for windows Net_DNS_Resolver class)

(were say only 1 MX exists and its mail.mydomain.com)

 

This is one of the things where you CAN check but you may not want to.. this requires your server connecting to another server to do some checks.. of course its useful if you want to have check they are valid before sending bulk mail or something like that.. personally i use a JS RegEX, once submitted re-check via a PHP RegEx then send a link.. but it depends on the project ;)

actually i want to use this script on  "refer to friends page"

where user will put five email addresses in five input boxes and i am using smpt validation script to validate these five email addresses(doesn't matter the domain name whatever it is but it should check whether the email is valid or not (should not be faked emil address like abc@yahoo.com or abc@gmail.com)).

currently it is checking the domain names

eg if i put the incorrect domain name like yahsoo.com then it prints the error email address is not valid

but with wrong email address like dfsfsd@yahoo.com it says the valid email address

 

can u tell me that how much time this script will take to validate the five email addresses.

and if possible send me code on karan23424@yahoo.com

 

and i want this functionality on submit button

 

Thanx

  • 1 month later...

Of couse you can check if its real!!

 

can you check if its used by the person whos entered it.. no (well only via an activation link or that sort of thing)

 

okay let get down to business

 

First whats the problem you say you have already tried a lot of scripts from net but all went in vain,

 

what are you trying to do ?

 

To check if a email is "Real" you need to get the email address and checks its valid but doing the following (in order)

[*]Its a Valid Email address format

[*]The domain exists

[*]get the MX (mail exchange) for the domain

[*]if theirs more than one MX then check each in priorities order

[*]if all MX fail attempt to use the domain

[*]Pass the email address to the Mail Exchange and see if the address is accepted as valid on that domain

 

So for example (use a simple regex ie basic example '%\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b%i')

A = madtechie@notmydomain

B = madtechie@notmydomain.com

C = NOTmadtechie@mydomain.com

D = madtechie@mydomain.com

 

1. Its a Valid Email address format?

A = False

B = True

C = True

D = True

So A has Failed it won't be tested anymore

 

2. The domain exists (ie ping the domain) sockets are fine here

B = false

C = True

D = True

So B has Failed it won't be tested anymore

 

-. get the MX (mail exchange) for the domain  (use getmxrr() or for windows Net_DNS_Resolver class)

(were say only 1 MX exists and its mail.mydomain.com)

 

3. Pass the C & D email address to the mail.mydomain.com and see if the address is accepted as valid on that domain. (again sockets)

open socket mail.mydomain.com:25

send ("HELO mydomain.com")

C = send("MAIL FROM: <NOTmadtechie@mydomain.com@mydomain.com>");

D = send("MAIL FROM: <madtechie@mydomain.com@mydomain.com>");

 

C = send("RCPT TO: <NOTmadtechie@mydomain.com@mydomain.com>");

D = send("RCPT TO: <madtechie@mydomain.com@mydomain.com>");

 

Return

C = code (not 250) No valid mailbox

D = code(250) Valid Mailbox

 

So C has Failed it won't be tested anymore

 

Okay so only D passed all thus its a valid email

 

So send an email to that email address with a activation link when thats url is used its done :D

 

EDIT:

LOL took me a while to type so missed a few replies

 

Dear MadTechie

Can you explain on step #3. This is the best answer so far i found whole net(but need little explain).

While the method described above can prove useful, I submit it is definitely not bulletproof and preventing the use of email addresses that fail that validation will do nothing but tick off users entering "real" email addresses that simply fail that validation for any number of reasons - as stated in this comment in the manual: http://fr2.php.net/manual/en/function.checkdnsrr.php#75452

 

I have used perfectly valid email addresses in the past which failed such validations because I was using an address that was simply redirected and there was no DNS record for the mailserver or where I used a "custom" alias that would go to a "catch-all" account.

While the method described above can prove useful, I submit it is definitely not bulletproof and preventing the use of email addresses that fail that validation will do nothing but tick off users entering "real" email addresses that simply fail that validation for any number of reasons - as stated in this comment in the manual: http://fr2.php.net/manual/en/function.checkdnsrr.php#75452

 

I have used perfectly valid email addresses in the past which failed such validations because I was using an address that was simply redirected and there was no DNS record for the mailserver or where I used a "custom" alias that would go to a "catch-all" account.

Thank you very much for your reply. I read your post yesterday while tring to find something usefull. But here is my code so far i tring to complete.

 

$email = "jdavide22@hotmail.com";
$myDomain = "mydomain.com";

	if(!preg_match ("/^[\w\.-]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]+$/", $email)){
		die("FORMAT IS NOT VALID");										# IF MAIL ADDRESS IS NOT WELL FORMATED
	} else{
		list($username,$domain)=split('@',$email);

		if(!checkdnsrr($domain,'MX')){									# CHECKING DOMAIN EXIST OR NOT
																		# DOMAIN DOES NOT EXIST
			die("DOMAIN DOES NOT EXIST");
		} else{ 														# DOMAIN EXIST
			$fp = fsockopen($domain, 25, $errno, $errstr, 10);			# SOCKET CONNECTION...
			if(!$fp) die("SOCKET CONNECTION FAILED");					# SOCKET CONNECTION FAILED...

			$request = "HELO $domain\n";
			fputs($fp,$request);

//				send("HELO".$myDomain);
//				send_data("MAIL FROM: <".$email."@".$myDomain.">");
//				send_data("RCPT TO: <".$email."@".$myDomain.">");
		}
	}
	fclose($fp);

okay, in fsockopen part if i type("mail.".$domain, 25, $errno, $errstr, 10) it works in hotmail but fail for japanese domain.

So, what i really want to do is exactly MadTechie 's way. I have mail list and i want to check them if it is valid. If it is valid leave alone if not then update db make flg 1 and then skip for sending mail next time.

This link is exactly what i want : http://www.hq42.net/net_tools/test_email_addr.php

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.