Make WordPress Core

Changeset 48601


Ignore:
Timestamp:
07/24/2020 05:38:27 PM (6 years ago)
Author:
whyisjake
Message:

Mail: Ensure that a server hostname can be set by using network_home_url().

Due to the varying server setups, $_SERVER['SERVER_NAME']; can't reliably ensure that there will be a relevant host that could be used as the hostname in an email. Since the network_home_url() is set at this point, and is filterable, this should better enable emails to be sent from the server.

Fixes #25239.
Props layotte, SergeyBiryukov, nacin, sreedoap, szepe.viktor, jesin, kitchin, mensmaximus, mt8.biz, Grzegorz.Janoszka, cbutlerjr, dd32, BjornW, neodjandre, BjornW, Ipstenu, ocean90, danielbachhuber, desmith, joemcgill, jdgrimes, riasat, derekakelly, swissspidy, lilmike, tsimmons, robert.peake, DavidAnderson, cloudstek, pigdog234, BjornW, rawrly, pessoft, RedSand, seayou, dvershinin, bastho, chesio, Starbuck, afragen, ocean90, whyisjake.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

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

    r48511 r48601  
    953953
    954954        if ( '' === $admin_email ) {
    955                 $admin_email = 'support@' . $_SERVER['SERVER_NAME'];
     955                $admin_email = 'support@' . wp_parse_url( network_home_url(), PHP_URL_HOST );
    956956        }
    957957
    … …  
    10801080
    10811081        if ( '' === $admin_email ) {
    1082                 $admin_email = 'support@' . $_SERVER['SERVER_NAME'];
     1082                $admin_email = 'support@' . wp_parse_url( network_home_url(), PHP_URL_HOST );
    10831083        }
    10841084
    … …  
    16641664
    16651665        if ( '' === $admin_email ) {
    1666                 $admin_email = 'support@' . $_SERVER['SERVER_NAME'];
     1666                $admin_email = 'support@' . wp_parse_url( network_home_url(), PHP_URL_HOST );
    16671667        }
    16681668
    … …  
    17561756
    17571757        if ( '' === $admin_email ) {
    1758                 $admin_email = 'support@' . $_SERVER['SERVER_NAME'];
     1758                $admin_email = 'support@' . wp_parse_url( network_home_url(), PHP_URL_HOST );
    17591759        }
    17601760
  • trunk/src/wp-includes/pluggable.php

    r48590 r48601  
    331331                if ( ! isset( $from_email ) ) {
    332332                        // Get the site domain and get rid of www.
    333                         $sitename = strtolower( $_SERVER['SERVER_NAME'] );
     333                        $sitename = wp_parse_url( network_home_url(), PHP_URL_HOST );
    334334                        if ( 'www.' === substr( $sitename, 0, 4 ) ) {
    335335                                $sitename = substr( $sitename, 4 );
    … …  
    16511651                }
    16521652
    1653                 $wp_email = 'wordpress@' . preg_replace( '#^www\.#', '', strtolower( $_SERVER['SERVER_NAME'] ) );
     1653                $wp_email = 'wordpress@' . preg_replace( '#^www\.#', '', wp_parse_url( network_home_url(), PHP_URL_HOST ) );
    16541654
    16551655                if ( '' === $comment->comment_author ) {
    … …  
    28322832        }
    28332833endif;
    2834 
Note: See TracChangeset for help on using the changeset viewer.