[wp-trac] [WordPress Trac] #48951: email_too_short is not good email validation candidate

WordPress Trac noreply at wordpress.org
Thu Aug 7 10:34:41 UTC 2025


#48951: email_too_short is not good email validation candidate
-----------------------------+------------------------------
 Reporter:  dingo_d          |       Owner:  (none)
     Type:  feature request  |      Status:  closed
 Priority:  low              |   Milestone:  Awaiting Review
Component:  Mail             |     Version:  5.4
 Severity:  trivial          |  Resolution:  worksforme
 Keywords:  2nd-opinion      |     Focuses:
-----------------------------+------------------------------
Changes (by SirLouen):

 * status:  new => closed
 * resolution:   => worksforme


Comment:

 > The problem comes when you work with decoupled WordPress, and the front
 end is using custom validation that allows such emails, but WordPress
 doesn't so you don't have consistent behavior. Plus this is just wrong, as
 the official specification allows such mails.

 This is correct, despite ICANN discourages the use of no dot domains, RFC
 allows it.

 But since we are using `is_mail` as the current mail validator, there is a
 filter that allows doing this:

 https://github.com/SirLouen/wordpress-
 develop/blob/f152321f2fe5665cb28486de04fa54bdf58fb252/src/wp-
 includes/formatting.php#L3604-L3608

 So you can simply add something like this:

 {{{
 function no_periods_domain( $is_email, $email, $context ) {
     if ( 'domain_no_periods' === $context ) {
         return $email;
     }
     return $is_email;
 }
 add_filter( 'is_email', 'no_periods_domain', 10, 3 );
 }}}

 And you will be able to use those formats without trouble.

 {{{
 Return-Path: <supertester at example-test-2>
 Received: from localhost (unknown [172.20.0.1])
         by 144d19eeeff3 (Mailpit) with SMTP
         for <admin at mailserver1>; Thu, 7 Aug 2025 10:34:17 +0000 (UTC)
 Date: Thu, 7 Aug 2025 10:34:17 +0000
 To: admin at mailserver1
 From: WordPress <supertester at example-test-2>
 Subject: Baseline test
 Message-ID: <DcDMxyXzLdkJ4D6bdgNGeKaAa5TNkWcdChUNS4S4 at localhost>
 X-Mailer: PHPMailer 6.9.3 (https://github.com/PHPMailer/PHPMailer)
 x-my-things: thing3
 MIME-Version: 1.0
 Content-Type: text/plain; charset=UTF-8

 See attachments.
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/48951#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list