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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dan at bigbirdmedia dot com
New email:
PHP Version: OS:

 

 [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: Sat Jun 15 21:01:28 2024 UTC