php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50204 FILTER_VALID_EMAIL passes without top level domain
Submitted: 2009-11-17 16:01 UTC Modified: 2009-11-17 18:14 UTC
From: brian dot sulzen at aescreations dot com Assigned:
Status: Not a bug Package: Filter related
PHP Version: 5.2.11 OS: FreeBSD 6.3
Private report: No CVE-ID: None
 [2009-11-17 16:01 UTC] brian dot sulzen at aescreations dot com
Description:
------------
FILTER_VALIDATE_EMAIL is passes addresses with out top level domain (i.e., .com, .net, etc).

Reproduce code:
---------------
<?php    
    
$email_address = "test2_mail@example";    
var_dump(filter_var($email_address, FILTER_VALIDATE_EMAIL));    
                                                                
$email_address = "test-mail@example.com";    
var_dump(filter_var($email_address, FILTER_VALIDATE_EMAIL));    
    
$email_address = "test+mail@example.com";    
var_dump(filter_var($email_address, FILTER_VALIDATE_EMAIL));    
                                                                        
?>



Expected result:
----------------
bool(false)
string(21) "test-mail@example.com"
string(21) "test+mail@example.com"

Actual result:
--------------
string(18) "test2_mail@example"
string(21) "test-mail@example.com"
string(21) "test+mail@example.com" 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-11-17 16:06 UTC] rasmus@php.net
That's not a bug.  It only validates that the address looks valid, not whether the email address actually exists.  email addresses without a tld are perfectly valid.  Try sending an email to: root@localhost for example.  Or on my personal server rasmus@colo works.  Same for Intranet applications.  You can have all sorts of valid email addresses that have no TLD.
 [2009-11-17 18:14 UTC] brian dot sulzen at aescreations dot com
Was not sure if it was a bug or not. All I know is before the php 
portupgrade, addresses without a top level domain would not pass 
validation.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Dec 05 21:03:39 2021 UTC