php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66681 filter_var($email,FILTER_VALIDATE_EMAIL) error
Submitted: 2014-02-10 05:16 UTC Modified: 2014-12-30 10:42 UTC
From: dan at bigbirdmedia dot com Assigned:
Status: No Feedback Package: Filter related
PHP Version: Irrelevant OS: Apache/Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
50 + 46 = ?
Subscribe to this entry?

 
 [2014-02-10 05:16 UTC] dan at bigbirdmedia dot com
Description:
------------
---
From manual page: http://www.php.net/filter.examples.validation
---

It seems that the filter_var() function doesn't quite work for all emails, at least not consistently.

Test script:
---------------
<?php

function domainExists($email) {
  if(filter_var($email,FILTER_VALIDATE_EMAIL)) {
    list($user, $domain) = explode('@', $email);
    if(checkdnsrr($domain, 'MX')) {
      return TRUE;
    }
    else {
      return FALSE;
    }
  }
  else {
    return FALSE;
  }
}

$rm = 'jane_doe@hotmail.com';

if(domainExists($rm) === TRUE) {
  echo '<p>It worked!</p>';
}
else {
  echo '<p>It didn\'t work!</p>';
}

?>

Expected result:
----------------
I expect the function in the test/sample script to return true and echo '<p>It worked!</p>'.

Actual result:
--------------
The actual result is '<p>It didn\'t work!</p>'.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-02-10 05:24 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2014-02-10 05:24 UTC] requinix@php.net
Works for me.

Your function returns false if the filter_var check fails or the checkdnsrr check fails. You need to figure out which is happening.
And the PHP version is not irrelevant. What are you using?
 [2014-12-30 10:42 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 16:01:31 2024 UTC