Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Jan 2012
    Location
    Sweden
    Posts
    32
    Thanks
    7
    Thanked 0 Times in 0 Posts

    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

  • #2
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,396
    Thanks
    8
    Thanked 1,078 Times in 1,069 Posts
    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.

    .

  • #3
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    You could also try using checkdnsrr
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #4
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,479
    Thanks
    0
    Thanked 635 Times in 625 Posts
    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/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #5
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,093
    Thanks
    51
    Thanked 506 Times in 493 Posts
    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.
    My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!

  • #6
    New Coder
    Join Date
    Jan 2012
    Location
    Sweden
    Posts
    32
    Thanks
    7
    Thanked 0 Times in 0 Posts
    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...

  • #7
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,479
    Thanks
    0
    Thanked 635 Times in 625 Posts
    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/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •