<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Comments on snippet: 'Check for valid email address'</title>
<link>http://snipplr.com</link>
<description>Snipplr comments feed'</description>
<language>en-us</language>
<pubDate>Mon, 13 Feb 2012 18:52:17 GMT</pubDate>
<item>
<title>Jotape said on 8/31/11</title>
<link>http://snipplr.com/view/2/check-for-valid-email-address/</link>
<description><![CDATA[ http://www.snipplr.com/view/58338/validate-email-and-domain/ ]]></description>
<pubDate>Wed, 31 Aug 2011 09:51:16 GMT</pubDate>
<guid>http://snipplr.com/view/2/check-for-valid-email-address/</guid>
</item>
<item>
<title>MikeNGarrett said on 2/18/11</title>
<link>http://snipplr.com/view/2/check-for-valid-email-address/</link>
<description><![CDATA[ filter_var($email, FILTER_VALIDATE_EMAIL); 

This either returns the email or false. ]]></description>
<pubDate>Fri, 18 Feb 2011 06:18:20 GMT</pubDate>
<guid>http://snipplr.com/view/2/check-for-valid-email-address/</guid>
</item>
<item>
<title>asdasDan said on 1/5/11</title>
<link>http://snipplr.com/view/2/check-for-valid-email-address/</link>
<description><![CDATA[ As many have noted, using custom regular expressions isn't necessary when filter_var options are available.

+1 to housecor as well. ]]></description>
<pubDate>Wed, 05 Jan 2011 16:47:39 GMT</pubDate>
<guid>http://snipplr.com/view/2/check-for-valid-email-address/</guid>
</item>
<item>
<title>alyssonweb said on 12/16/10</title>
<link>http://snipplr.com/view/2/check-for-valid-email-address/</link>
<description><![CDATA[ <a href="http://snipplr.com/view/45716/check-for-valid-email-address-rfc/">http://snipplr.com/view/45716/check-for-valid-email-address-rfc/</a> ]]></description>
<pubDate>Thu, 16 Dec 2010 09:24:42 GMT</pubDate>
<guid>http://snipplr.com/view/2/check-for-valid-email-address/</guid>
</item>
<item>
<title>alyssonweb said on 12/14/10</title>
<link>http://snipplr.com/view/2/check-for-valid-email-address/</link>
<description><![CDATA[ there is no reason to use if/else statement you can simply return preg_match();
http://snipplr.com/view/45702/check-for-valid-email-address-rfc/ ]]></description>
<pubDate>Tue, 14 Dec 2010 20:00:28 GMT</pubDate>
<guid>http://snipplr.com/view/2/check-for-valid-email-address/</guid>
</item>
<item>
<title>Scriptor said on 12/14/10</title>
<link>http://snipplr.com/view/2/check-for-valid-email-address/</link>
<description><![CDATA[ @NaRzY - that code is nearly 3 years old. ]]></description>
<pubDate>Tue, 14 Dec 2010 14:03:16 GMT</pubDate>
<guid>http://snipplr.com/view/2/check-for-valid-email-address/</guid>
</item>
<item>
<title>NaRzY said on 11/4/10</title>
<link>http://snipplr.com/view/2/check-for-valid-email-address/</link>
<description><![CDATA[ if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {
	// Error message here
} ]]></description>
<pubDate>Thu, 04 Nov 2010 15:27:40 GMT</pubDate>
<guid>http://snipplr.com/view/2/check-for-valid-email-address/</guid>
</item>
<item>
<title>NaRzY said on 11/4/10</title>
<link>http://snipplr.com/view/2/check-for-valid-email-address/</link>
<description><![CDATA[ Way too much of an overkill. You should be using PHP's filter_var. Example below: ]]></description>
<pubDate>Thu, 04 Nov 2010 15:26:04 GMT</pubDate>
<guid>http://snipplr.com/view/2/check-for-valid-email-address/</guid>
</item>
<item>
<title>housecor said on 10/26/10</title>
<link>http://snipplr.com/view/2/check-for-valid-email-address/</link>
<description><![CDATA[ The code is unnecessarily verbose. There's no need to explicitly return true/false with an if/else. This body will suffice:

return (preg_match("/[a-zA-Z0-9_-.+]+@[a-zA-Z0-9-]+.[a-zA-Z]+/", $email) > 0); ]]></description>
<pubDate>Tue, 26 Oct 2010 13:45:35 GMT</pubDate>
<guid>http://snipplr.com/view/2/check-for-valid-email-address/</guid>
</item>
<item>
<title>Calvista said on 9/16/10</title>
<link>http://snipplr.com/view/2/check-for-valid-email-address/</link>
<description><![CDATA[ +1 for @jfherring ]]></description>
<pubDate>Thu, 16 Sep 2010 16:10:01 GMT</pubDate>
<guid>http://snipplr.com/view/2/check-for-valid-email-address/</guid>
</item>
<item>
<title>jfherring said on 6/19/10</title>
<link>http://snipplr.com/view/2/check-for-valid-email-address/</link>
<description><![CDATA[ http://www.snipplr.com/view/10897/valid-email-address-filter/ ]]></description>
<pubDate>Sat, 19 Jun 2010 09:17:35 GMT</pubDate>
<guid>http://snipplr.com/view/2/check-for-valid-email-address/</guid>
</item>
<item>
<title>darksider said on 4/30/10</title>
<link>http://snipplr.com/view/2/check-for-valid-email-address/</link>
<description><![CDATA[ apart from the little typos/errors noted by the others,
this is a great snippet.
Short, Sweet, and very useful.
thanks and good work, dude - keep it up!!

-darksider- ]]></description>
<pubDate>Fri, 30 Apr 2010 20:45:35 GMT</pubDate>
<guid>http://snipplr.com/view/2/check-for-valid-email-address/</guid>
</item>
<item>
<title>Masis said on 2/9/10</title>
<link>http://snipplr.com/view/2/check-for-valid-email-address/</link>
<description><![CDATA[ You can try the next:
function check_email_address($email) {
  // First, we check that there's one @ symbol, 
  // and that the lengths are right.
  if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
    // Email invalid because wrong number of characters 
    // in one section or wrong number of @ symbols.
    return false;
  }
  // Split it into sections to make life easier
  $email_array = explode("@", $email);
  $local_array = explode(".", $email_array[0]);
  for ($i = 0; $i < sizeof($local_array); $i++) {
    if
(!ereg("^(([A-Za-z0-9!#$%&amp;'*+/=?^_`{|}~-][A-Za-z0-9!#$%&amp;
↪'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$",
$local_array[$i])) {
      return false;
    }
  }
  // Check if domain is IP. If not, 
  // it should be valid domain name
  if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) {
    $domain_array = explode(".", $email_array[1]);
    if (sizeof($domain_array) < 2) {
        return false; // Not enough parts to domain
    }
    for ($i = 0; $i < sizeof($domain_array); $i++) {
      if
(!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|
↪([A-Za-z0-9]+))$",
$domain_array[$i])) {
        return false;
      }
    }
  }
  return true;
}

Also you can search for demo email <a href=http://phpforms.net/php-forms.html>php form</a> and look a right code ]]></description>
<pubDate>Tue, 09 Feb 2010 10:44:48 GMT</pubDate>
<guid>http://snipplr.com/view/2/check-for-valid-email-address/</guid>
</item>
<item>
<title>ginoplusio said on 12/27/09</title>
<link>http://snipplr.com/view/2/check-for-valid-email-address/</link>
<description><![CDATA[ Here is another SMTP mail validation function in php: 
http://snipplr.com/view/25505/validate-emails-with-smtp-and-php/ ]]></description>
<pubDate>Sun, 27 Dec 2009 06:09:12 GMT</pubDate>
<guid>http://snipplr.com/view/2/check-for-valid-email-address/</guid>
</item>
<item>
<title>hm2k said on 12/21/09</title>
<link>http://snipplr.com/view/2/check-for-valid-email-address/</link>
<description><![CDATA[ Try this: [validemail.org](http://validemail.org/ "validemail") ]]></description>
<pubDate>Mon, 21 Dec 2009 08:31:58 GMT</pubDate>
<guid>http://snipplr.com/view/2/check-for-valid-email-address/</guid>
</item>
<item>
<title>svenito said on 9/30/09</title>
<link>http://snipplr.com/view/2/check-for-valid-email-address/</link>
<description><![CDATA[ Simplified reg ex for this: /\S+@\S+\.\D+/ ]]></description>
<pubDate>Wed, 30 Sep 2009 07:56:04 GMT</pubDate>
<guid>http://snipplr.com/view/2/check-for-valid-email-address/</guid>
</item>
<item>
<title>bucabay said on 9/3/09</title>
<link>http://snipplr.com/view/2/check-for-valid-email-address/</link>
<description><![CDATA[ The correct link:

To check whether an email address actually exists on the mailserver, use the [PHP SMTP Email Validation][1] class.

[1]: http://code.google.com/p/php-smtp-email-validation/ "PHP SMTP Email Validation" ]]></description>
<pubDate>Thu, 03 Sep 2009 09:52:45 GMT</pubDate>
<guid>http://snipplr.com/view/2/check-for-valid-email-address/</guid>
</item>
<item>
<title>bucabay said on 9/3/09</title>
<link>http://snipplr.com/view/2/check-for-valid-email-address/</link>
<description><![CDATA[ To check whether an email address actually exists on the mailserver, use the [PHP SMTP Email Validation][1] class. 

[1] http://code.google.com/p/php-smtp-email-validation/ "PHP SMTP Email Validation" ]]></description>
<pubDate>Thu, 03 Sep 2009 09:51:56 GMT</pubDate>
<guid>http://snipplr.com/view/2/check-for-valid-email-address/</guid>
</item>
<item>
<title>Unreal said on 2/28/09</title>
<link>http://snipplr.com/view/2/check-for-valid-email-address/</link>
<description><![CDATA[ From w3schools - http://www.w3schools.com/php/filter_validate_email.asp ]]></description>
<pubDate>Sat, 28 Feb 2009 18:55:54 GMT</pubDate>
<guid>http://snipplr.com/view/2/check-for-valid-email-address/</guid>
</item>
<item>
<title>dominicsayers said on 2/26/09</title>
<link>http://snipplr.com/view/2/check-for-valid-email-address/</link>
<description><![CDATA[ http://snipplr.com/view/11616/rfccompliant-email-address-validator/

And check out a head-to-head of free validators here: http://www.dominicsayers.com/isemail/ ]]></description>
<pubDate>Thu, 26 Feb 2009 12:05:21 GMT</pubDate>
<guid>http://snipplr.com/view/2/check-for-valid-email-address/</guid>
</item>
<item>
<title>koncept said on 10/5/08</title>
<link>http://snipplr.com/view/2/check-for-valid-email-address/</link>
<description><![CDATA[ http://snipplr.com/view/8844/rfc822-compliant-email-address-validator/ ]]></description>
<pubDate>Sun, 05 Oct 2008 00:56:42 GMT</pubDate>
<guid>http://snipplr.com/view/2/check-for-valid-email-address/</guid>
</item>
<item>
<title>liorsp0 said on 4/15/08</title>
<link>http://snipplr.com/view/2/check-for-valid-email-address/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Tue, 15 Apr 2008 08:44:14 GMT</pubDate>
<guid>http://snipplr.com/view/2/check-for-valid-email-address/</guid>
</item>
<item>
<title>g0dbrz said on 3/5/08</title>
<link>http://snipplr.com/view/2/check-for-valid-email-address/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Wed, 05 Mar 2008 09:15:22 GMT</pubDate>
<guid>http://snipplr.com/view/2/check-for-valid-email-address/</guid>
</item>
<item>
<title>guidorossi said on 1/11/08</title>
<link>http://snipplr.com/view/2/check-for-valid-email-address/</link>
<description><![CDATA[ <p>Simplest way. PHP5 only</p>

<p></p>

<p>http://www.w3schools.com/php/filter<em>validate</em>email.asp</p>
 ]]></description>
<pubDate>Fri, 11 Jan 2008 22:06:44 GMT</pubDate>
<guid>http://snipplr.com/view/2/check-for-valid-email-address/</guid>
</item>
<item>
<title>gdonald said on 1/12/07</title>
<link>http://snipplr.com/view/2/check-for-valid-email-address/</link>
<description><![CDATA[ <p>Doesn't seem to allow PHP tags.  Here's another try on those sample scripts:</p>

<p>Here are my sample scripts:</p>

email_bad.php:

<p>error<em>reporting( E</em>ALL );</p>

<p>function is<em>valid</em>email( $email )
{
  if( preg<em>match( "/[a-zA-Z0-9</em>-.+]+@[a-zA-Z0-9-]+.[a-zA-Z]+/", $email ) > 0 )
    return true;
  else
    return false;
}</p>

<p>$emails = array(  'br0k3n',
                  'fred_dred@aol.com',
                  'fred-dred@aol.com',
                  'fred.dred@aol.com',
                  'fred+dred@aol.com' );</p>

<p>foreach( $emails as $email )
{
  echo $email . ' is' . ( is<em>valid</em>email( $email ) ? '' : ' not' )  . " valid\n";
}</p>

email_fixed.php:

<p>error<em>reporting( E</em>ALL );</p>

<p>function is<em>valid</em>email( $email )
{
  return preg<em>match( '/[.+a-zA-Z0-9</em>-]+@[a-zA-Z0-9-]+.[a-zA-Z]+/', $email );
}</p>

<p>$emails = array(  'br0k3n',
                  'fred_dred@aol.com',
                  'fred-dred@aol.com',
                  'fred.dred@aol.com',
                  'fred+dred@aol.com' );</p>

<p>foreach( $emails as $email )
{
  echo $email . ' is' . ( is<em>valid</em>email( $email ) ? '' : ' not' )  . " valid\n";
}</p>
 ]]></description>
<pubDate>Fri, 12 Jan 2007 12:54:48 GMT</pubDate>
<guid>http://snipplr.com/view/2/check-for-valid-email-address/</guid>
</item>
<item>
<title>gdonald said on 1/12/07</title>
<link>http://snipplr.com/view/2/check-for-valid-email-address/</link>
<description><![CDATA[ <p>The regular expression</p>

<p>[a-zA-Z0-9_-.+]+@[a-zA-Z0-9-]+.[a-zA-Z]+</p>

<p>does not compile.</p>

<p>When a dash is used in a character class it indicates a range.</p>

<p>_-. is not a valid range.</p>

<p>A corrected version could be</p>

<p>[.+a-zA-Z0-9_-]+@[a-zA-Z0-9-]+.[a-zA-Z]+</p>

<p>or</p>

<p>[-a-zA-Z0-9_.+]+@[a-zA-Z0-9-]+.[a-zA-Z]+</p>

<p>When the dash is moved to the beginning or end of the character class it is automatically not part of a range and instead does a literal match on the dash character.</p>

<p>Here are my sample scripts:</p>

email_bad.php:

!/usr/bin/php

<p></p>

email_fixed.php:

!/usr/bin/php

<p></p>
 ]]></description>
<pubDate>Fri, 12 Jan 2007 12:53:09 GMT</pubDate>
<guid>http://snipplr.com/view/2/check-for-valid-email-address/</guid>
</item>
</channel>
</rss>
