WordPress.org

Make WordPress Core

Ticket #40810: 40810.patch

File 40810.patch, 688 bytes (added by pessoft, 2 years ago)

Use hostname if SERVER_NAME is not available for default sender of wp_mail function

  • src/wp-includes/pluggable.php

     
    327327
    328328        if ( !isset( $from_email ) ) {
    329329                // Get the site domain and get rid of www.
    330                 $sitename = strtolower( $_SERVER['SERVER_NAME'] );
     330                // If SERVER_NAME is not available, hostname will be used.
     331                if ( !empty ( $_SERVER['SERVER_NAME'] ) ) {
     332                    $sitename = strtolower( $_SERVER['SERVER_NAME'] );
     333                } else {
     334                    $sitename = strtolower( php_uname( 'n' ));
     335                }
    331336                if ( substr( $sitename, 0, 4 ) == 'www.' ) {
    332337                        $sitename = substr( $sitename, 4 );
    333338                }