Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Validate email address in PHP [duplicate]

Possible Duplicate:
How to validate an emailaddress in PHP

I was wondering what everyone is doing in regards to validating email addresses and how extensive the validation needs to be.

For example, of those methods, which one is preferred and why?

  1. Extensive check: http://www.linuxjournal.com/article/9585?page=0,3
  2. PHP filter: http://php.net/manual/en/filter.filters.validate.php
  3. Eregi: http://www.totallyphp.co.uk/code/validate_an_email_address_using_regular_expressions.htm
  4. Preg match with DNS check: http://www.soaptray.com/blog/2008/04/validate-email-addresses-using-php/

My goal is to find a good and solid solution for the average project, so when the time comes to validate an email address, I know exactly what I'm going to use.

Any feedback much appreciated!

-Ryan

like image 547
NightHawk Avatar asked Jun 26 '26 07:06

NightHawk


2 Answers

Use PHP’s build-in filters for a syntactic validation and send a verification e-mail for an intention confirmation.

like image 76
Gumbo Avatar answered Jun 28 '26 22:06

Gumbo


http://www.regular-expressions.info/email.html has the RFC2822 recommended reg ex.

like image 21
Andrew Sledge Avatar answered Jun 28 '26 22:06

Andrew Sledge



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!