3

Possible Duplicates:
What’s wrong with this RegEx for validating emails?
How to verify if a email address exists?
How to check if an email address exists without sending an email?

I was wondering if it was possible to validate an email address with php (w/library or without). When I say validate I don't mean a regex match I mean verify that the email address is actually a valid address in which emails can be sent.

Community
  • 1
  • 1
Albinoswordfish
  • 1,949
  • 7
  • 34
  • 50
  • Actually, according to [google](http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=Validate+Email+site:stackoverflow.com) this question has been discussed 18,300 times on this site. – Xeoncross Aug 17 '10 at 04:01
  • 3
    Before you downvote the question as duplicate trouble yourself with reading more than the title. If you read the question you will see he is not asking about regex. – Majid Fouladpour Aug 17 '10 at 04:03
  • If you are doing a verification on your form using ajax to check email addresses in addition to regex validation. A simple thing you can do is verify the domain of the email address is valid. In this context, I think that's a good enough test for an email address. – DMin Aug 17 '10 at 04:04
  • 1
    @Majid this is an **exact duplicate**, be it php or otherwise: http://stackoverflow.com/questions/2750175/how-to-verify-if-a-email-address-exists – bcosca Aug 17 '10 at 04:06

2 Answers2

2

No, the only way you can truly validate an email is to send it an email containing a validation link.

Whit
  • 1,149
  • 1
  • 12
  • 28
  • 1
    Of course, that can be done with PHP. – David Z Aug 17 '10 at 03:56
  • So what if I used the mail() function and it returned false? – Albinoswordfish Aug 17 '10 at 03:56
  • 2
    All that means is the PHP function failed. That says very little about whether the email address actually exists. – Whit Aug 17 '10 at 03:59
  • @Albino That still doesn't tell you anything – NullUserException Aug 17 '10 at 03:59
  • It is blatantly false that you can not validate an email. There are [some RFC validation libraries](http://www.dominicsayers.com/isemail/) available that will validate any internet-routable email address as *well-formed*. They won't validate local addresses or local domains properly. However, it is very true that sending an email to the address in question is *the best* way to ensure it's legit. – Charles Aug 17 '10 at 04:06
2

That is verification rather than validation, and yes it is possible and here is a tutorial which shows how you go about it.

Majid Fouladpour
  • 29,356
  • 21
  • 76
  • 127