Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-21-2012, 05:29 PM   PM User | #1
webjoker
New Coder

 
Join Date: Jan 2012
Location: Sweden
Posts: 32
Thanks: 7
Thanked 0 Times in 0 Posts
webjoker is an unknown quantity at this point
How do i tell my php to check if the email is valid?

Hello,

I've done a PhP code to send a mail when i click at a submit button. But a problem is that i can type any email adress even if it's valid or not valid. So my question is, how do i tell my PhP code to check if that email exists.

Regards: Webjoker
webjoker is offline   Reply With Quote
Old 01-21-2012, 05:53 PM   PM User | #2
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,046
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
You really can't.

Unless you email a code to the user, and they have to check their email to confirm.
You've probably experienced that tons of times.

You can validate it though.
Make sure the structure is correct xxx@xxx.xxx
with the @ and . in the proper order and they exist.

Another way is to extract the part after @ and ping or try to open
a file on that website. Usually, the part after @ is a domain.
Like: @yahoo.com or @msn.com or @gmail.com
You see if the "email" domain part is valid.
If I were to enter "mlseim@dfslkjf.com" ... dfslkjf.com is not a valid domain,
so I'm probably lying about my email address.

That's about the best you can do.

.
mlseim is offline   Reply With Quote
Old 01-21-2012, 06:41 PM   PM User | #3
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
You could also try using checkdnsrr
__________________
||||If you are getting paid to do a job, don't ask for help on it!||||
_Aerospace_Eng_ is offline   Reply With Quote
Old 01-21-2012, 09:35 PM   PM User | #4
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,465
Thanks: 0
Thanked 499 Times in 491 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
You could try sending an 'EHLO ' or 'VRFY: ' request to their mail server to see if it will respond that the email address exists. This is unlikely to work though as most mail servers now block responding to those types of request as it makes it too easy for spammers to find out what addresses exist on a given domain.
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote
Old 01-21-2012, 09:38 PM   PM User | #5
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,516
Thanks: 45
Thanked 440 Times in 429 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
Quote:
Originally Posted by felgall View Post
You could try sending an 'EHLO ' or 'VRFY: ' request to their mail server to see if it will respond that the email address exists. This is unlikely to work though as most mail servers now block responding to those types of request as it makes it too easy for spammers to find out what addresses exist on a given domain.
I had code for that, I tried it on a range of addresses in my contacts and only about 15-20% gave a usable answer. In short, it's pointless. The best way is send a link and let the user validate it.
__________________
Please wrap your code in [php] tags. It is a sticky topic and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote
Old 01-21-2012, 09:49 PM   PM User | #6
webjoker
New Coder

 
Join Date: Jan 2012
Location: Sweden
Posts: 32
Thanks: 7
Thanked 0 Times in 0 Posts
webjoker is an unknown quantity at this point
Thank you for all of your answer, i will read what u've typed. And try to make the best out of it! Thank you all...
webjoker is offline   Reply With Quote
Old 01-21-2012, 10:35 PM   PM User | #7
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,465
Thanks: 0
Thanked 499 Times in 491 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
Quote:
Originally Posted by tangoforce View Post
I had code for that, I tried it on a range of addresses in my contacts and only about 15-20% gave a usable answer. In short, it's pointless. The best way is send a link and let the user validate it.
I agree. I am surprised that you got such a high percentage of responses as that. I only got about that level of responses about five years ago when I tried it and i would have thought the percentage would be lower by now.

I agree that the only effective way is a link in the email for the person to click on to acknowledge that they received the email and actually wanted to receive more.
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote
Reply

Bookmarks

Tags
email, exists, php, valid, web

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:06 AM.


Advertisement
Log in to turn off these ads.