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.

4
  • Actually, according to google this question has been discussed 18,300 times on this site. Commented Aug 17, 2010 at 4: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. Commented Aug 17, 2010 at 4: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. Commented Aug 17, 2010 at 4:04
  • 1
    @Majid this is an exact duplicate, be it php or otherwise: stackoverflow.com/questions/2750175/… Commented Aug 17, 2010 at 4:06

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you, it's not full proof but it will be suitable for what I'm doing
The regex in that article is awful. Please use a RFC compliant validator instead.
I won't be using the regex, but I like the idea of using DNS to at least verify the hostname.
2

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

5 Comments

Of course, that can be done with PHP.
So what if I used the mail() function and it returned false?
All that means is the PHP function failed. That says very little about whether the email address actually exists.
@Albino That still doesn't tell you anything
It is blatantly false that you can not validate an email. There are some RFC validation libraries 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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.