diff --git src/wp-includes/pluggable.php src/wp-includes/pluggable.php
index e5b3e9f8c1..211e10a190 100644
|
|
|
if ( ! function_exists( 'wp_mail' ) ) : |
| 330 | 330 | |
| 331 | 331 | if ( ! isset( $from_email ) ) { |
| 332 | 332 | // Get the site domain and get rid of www. |
| 333 | | $sitename = strtolower( $_SERVER['SERVER_NAME'] ); |
| | 333 | // If SERVER_NAME is not available, hostname will be used. |
| | 334 | if ( !empty ( $_SERVER['SERVER_NAME'] ) ) { |
| | 335 | $sitename = strtolower( $_SERVER['SERVER_NAME'] ); |
| | 336 | } else { |
| | 337 | $sitename = strtolower( php_uname( 'n' )); |
| | 338 | } |
| 334 | 339 | if ( substr( $sitename, 0, 4 ) == 'www.' ) { |
| 335 | 340 | $sitename = substr( $sitename, 4 ); |
| 336 | 341 | } |
diff --git tests/phpunit/tests/mail.php tests/phpunit/tests/mail.php
index 951615136b..10f6e29045 100644
|
|
|
class Tests_Mail extends WP_UnitTestCase { |
| 359 | 359 | |
| 360 | 360 | $this->assertEquals( '', $mailer->Sender ); |
| 361 | 361 | } |
| | 362 | |
| | 363 | /** |
| | 364 | * Test that the From parameter has been set in phpmailer instance and not kept default. |
| | 365 | * Even in the case when SERVER_NAME is not available. |
| | 366 | * |
| | 367 | * @ticket 40810 |
| | 368 | */ |
| | 369 | public function test_wp_mail_from_not_default() { |
| | 370 | $_SERVER['SERVER_NAME'] = ''; |
| | 371 | wp_mail( 'user@example.org', 'Testing the From field', 'The From field should not be default.' ); |
| | 372 | |
| | 373 | $mailer = tests_retrieve_phpmailer_instance(); |
| | 374 | |
| | 375 | $this->assertNotEquals( 'root@localhost', $mailer->From ); |
| | 376 | } |
| 362 | 377 | |
| 363 | 378 | /** |
| 364 | 379 | * @ticket 35598 |