Make WordPress Core

Changes between Version 1 and Version 2 of Ticket #54465, comment 1


Ignore:
Timestamp:
07/12/2025 06:08:57 PM (13 months ago)
Author:
SirLouen

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #54465, comment 1

    v1 v2  
    33So basically, here is that this address `nameSurname.@gmail.com` is not valid.
    44
    5 [https://github.com/PHPMailer/PHPMailer/blob/0ff2d3c8ead628df2493537d9f91db962aa47718/src/PHPMailer.php#L1638 If you check PHPMailer code] basically its failing to spot a to, a cc or a bcc because [https://github.com/PHPMailer/PHPMailer/blob/0ff2d3c8ead628df2493537d9f91db962aa47718/src/PHPMailer.php#L1105 its unable to find a valid address] with an @ because of that dot,
     5[https://github.com/PHPMailer/PHPMailer/blob/0ff2d3c8ead628df2493537d9f91db962aa47718/src/PHPMailer.php#L1638 If you check PHPMailer code] basically was failing to spot a `To`, a `CC` or a `BCC` because PHPMailer was unable to find such valid address among these fields.
    66
    7 Maybe you could find some help with this little workaround: I was able to bypass this by setting the `wp_mail_from` filter like this:
    8 
    9 {{{
    10 add_filter('wp_mail_from', function($original_email_address) {
    11      return 'wordpress@server.local';
    12 });
    13 }}}
    14 
    15 Although using my example code for sending emails:
    16 
    17 {{{#!php
    18 <?php
    19 function send_email_menu() {
    20         add_menu_page(
    21                 'Send Test Email',
    22                 'TestEmail Sender',
    23                 'manage_options',
    24                 'send-email-page',
    25                 'send_email_page_html'
    26         );
    27 }
    28 add_action( 'admin_menu', 'send_email_menu' );
    29 
    30 function send_email_page_html() {
    31         ?>
    32         <div class="wrap">
    33                 <h1>Send a Test Email</h1>
    34                 <?php
    35                 if ( isset( $_POST['send_email'] ) && 1 === (int) $_POST['send_email'] ) {
    36             $to = "nameSurname.@gmail.com";
    37             $subject = "Subject";
    38             $body = "Message";
    39 
    40                         if ( wp_mail( $to, $subject, $body) ) {
    41                                 echo '<div class="notice notice-success is-dismissible"><p>Message successfully sent.</p></div>';
    42                         } else {
    43                                 echo '<div class="notice notice-error is-dismissible"><p>Message sending failed.</p></div>';
    44                         }
    45                 }
    46                 ?>
    47                 <form method="post" action="">
    48                         <input type="hidden" name="send_email" value="1">
    49                         <?php submit_button( 'Send Test Email' ); ?>
    50                 </form>
    51         </div>
    52         <?php
    53 }
    54 }}}
    55 
    56 
    57 We can see that this is the result when sending the email:
    58 
    59 {{{
    60 Return-Path: <wordpress@mailhog.local>
    61 Received: from localhost (wordpress-develop-php-1.wordpress-develop_wpdevnet. [172.18.0.3])
    62         by d2756ddb9791 (Mailpit) with SMTP
    63         for <nameSurname.@gmail.com>; Sat, 12 Jul 2025 17:25:56 +0000 (UTC)
    64 Date: Sat, 12 Jul 2025 17:25:56 +0000
    65 To: nameSurname.@gmail.com
    66 From: WordPress <wordpress@server.local>
    67 Subject: Subject
    68 Message-ID: <nUcLDNeY6tTDsDB3ReQB88Sfd3pQrxN0QRugoMqqR4@localhost>
    69 X-Mailer: PHPMailer 6.9.3 (https://github.com/PHPMailer/PHPMailer)
    70 MIME-Version: 1.0
    71 Content-Type: text/plain; charset=UTF-8
    72 
    73 Message
    74 }}}
    75 
    76 The email, although, is being delivered with `wp_mail` despite not being compliant. So I don't recommend you using an email like such
     7But probably in the latest versions of PHPMailer it should work (although it would be problematic with many clients, as it's not RFC compliant). In fact, I'm going to check this a little further using PHPMailer to see if it's not actually checking for this and report it upstream because it shouldn't. So I don't recommend using an email like such.
    778
    789Closing this for being `invalid` for not compliant with the RFC.