[wp-trac] [WordPress Trac] #25239: $_SERVER['SERVER_NAME'] not a reliable when generating email host names
WordPress Trac
noreply at wordpress.org
Fri May 5 14:40:37 UTC 2017
#25239: $_SERVER['SERVER_NAME'] not a reliable when generating email host names
-------------------------------------------------+-------------------------
Reporter: layotte | Owner:
Type: defect (bug) | SergeyBiryukov
Priority: normal | Status: reviewing
Component: Mail | Milestone: Future
Severity: normal | Release
Keywords: has-patch dev-feedback needs- | Version: 3.8
testing | Resolution:
| Focuses:
-------------------------------------------------+-------------------------
Comment (by tsimmons):
Replying to [comment:63 robert.peake]:
> @tsimmons @kitchin Indeed, seems like it might be most backwards-
compatible with the current solution to just do:
>
> {{{#!php
> <?php
> ...
> if ( !isset( $from_email ) ) {
> // Get the site domain and get rid of www.
> $sitename = strtolower( parse_url( get_home_url(
get_current_blog_id() ), PHP_URL_HOST ) );
> if ( substr( $sitename, 0, 4 ) == 'www.' ) {
> $sitename = substr( $sitename, 4 );
> }
>
> $from_email = 'wordpress@' . $sitename;
> ...
> }}}
@kitchin Y'all are exactly right. There are a vast number of domain
suffixes that are not taken into account with my patch. @robert.peake 's
fix is superior; I think I'm going to stick with the plugin from @BjornW
for now. Probably the only way to properly handle this is to utilize
something like https://github.com/jeremykendall/php-domain-parser in the
domain parsing.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/25239#comment:65>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list