diff --git a/src/wp-includes/pluggable.php b/src/wp-includes/pluggable.php
index c614ac0ed6..0ecbfabd0a 100644
a
|
b
|
function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() |
216 | 216 | require_once ABSPATH . WPINC . '/PHPMailer/SMTP.php'; |
217 | 217 | require_once ABSPATH . WPINC . '/PHPMailer/Exception.php'; |
218 | 218 | $phpmailer = new PHPMailer\PHPMailer\PHPMailer( true ); |
| 219 | |
| 220 | /** |
| 221 | * Set email validation to use WordPress's built-in is_email(). |
| 222 | * @ticket 50720 |
| 223 | */ |
| 224 | $phpmailer::$validator = 'is_email'; |
219 | 225 | } |
220 | 226 | |
221 | 227 | // Headers. |
diff --git a/tests/phpunit/includes/mock-mailer.php b/tests/phpunit/includes/mock-mailer.php
index edc36b9ec6..074e72aabb 100644
a
|
b
|
function reset_phpmailer_instance() { |
97 | 97 | $mailer = tests_retrieve_phpmailer_instance(); |
98 | 98 | if ( $mailer ) { |
99 | 99 | $GLOBALS['phpmailer'] = new MockPHPMailer( true ); |
| 100 | $GLOBALS['phpmailer']::$validator = 'is_email'; |
100 | 101 | return true; |
101 | 102 | } |
102 | 103 | |
diff --git a/tests/phpunit/tests/mail.php b/tests/phpunit/tests/mail.php
index d24d5e831a..f520e1e5a0 100644
a
|
b
|
public function test_phpmailer_exception_thrown() { |
407 | 407 | $this->assertEquals( 'wp_mail_failed', $call_args[0]->get_error_code() ); |
408 | 408 | $this->assertEquals( $expected_error_data, $call_args[0]->get_error_data() ); |
409 | 409 | } |
| 410 | |
| 411 | /** |
| 412 | * @ticket 50720 |
| 413 | */ |
| 414 | function test_phpmailer_validator() { |
| 415 | $phpmailer = $GLOBALS['phpmailer']; |
| 416 | $this->assertTrue( $phpmailer->validateAddress( 'foo@192.168.1.1' ), 'Assert PHPMailer accepts IP address email addresses' ); |
| 417 | } |
410 | 418 | } |