Make WordPress Core


Ignore:
Timestamp:
07/24/2020 05:38:27 PM (4 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.