Make WordPress Core

Changeset 48645

Timestamp:
07/27/2020 08:17:36 PM (4 years ago)
Author:
whyisjake
Message:

Mail: PHPMailer swap to use is_email for the default validator.

Prior to the PHPMailer update in 5.5, old version of the PHPMailer was setting the validator to 'auto' resulting in a sophisticated logic for determining what email address validation should be used. But the new version defaults to 'php', possibly leading to rejection of email addresses which were fine prior to the upgrade. Let's use the WordPress core function is_email() so that it can be fully pluggable.

Fixes #50720.
Props david.binda, ayeshrajans, Synchro, SergeyBiryukov, whyisjake.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/pluggable.php

    r48601 r48645  
    217217            require_once ABSPATH . WPINC . '/PHPMailer/Exception.php';
    218218            $phpmailer = new PHPMailer\PHPMailer\PHPMailer( true );
     219
     220
     221
     222
    219223        }
    220224
  • trunk/tests/phpunit/includes/mock-mailer.php

    r48058 r48645  
    9797    $mailer = tests_retrieve_phpmailer_instance();
    9898    if ( $mailer ) {
    99         $GLOBALS['phpmailer'] = new MockPHPMailer( true );
     99        $mailer             = new MockPHPMailer( true );
     100        $mailer::$validator = static function ( $email ) {
     101            return (bool) is_email( $email );
     102        };
     103
     104        $GLOBALS['phpmailer'] = $mailer;
    100105        return true;
    101106    }
  • trunk/tests/phpunit/tests/mail.php

    r48443 r48645  
    408408        $this->assertEquals( $expected_error_data, $call_args[0]->get_error_data() );
    409409    }
     410
     411
     412
     413
     414
     415
     416
     417
    410418}
Note: See TracChangeset for help on using the changeset viewer.