[wp-trac] [WordPress Trac] #37945: If from_email is not set and $_SERVER['SERVER_NAME'] is empty the from email address will be set to 'wordpress@' and thus is invalid

WordPress Trac noreply at wordpress.org
Mon Sep 5 11:28:07 UTC 2016


#37945: If from_email is not set and $_SERVER['SERVER_NAME'] is empty the from
email address will be set to 'wordpress@' and thus is invalid
--------------------------+-----------------------------
 Reporter:  BjornW        |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Mail          |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 In some WordPress server setups the $_SERVER['SERVER_NAME'] may not have
 been setup, so $_SERVER['SERVER_NAME'] is empty.

 For example Nginx (see http://nginx.org/en/docs/http/server_names.html)
 will set the server name to empty if none is set in the configuration, but
 afaik it is also possible for Apache to set the ServerName to an empty
 string.

 If the from_email address is *also* NOT set this will cause PHPMailer to
 throw an exception complaining about an invalid address. This will cause
 an infamous white screen.

 In https://core.trac.wordpress.org/ticket/32702 this was also mentioned
 but @boonebgorges thought the test was to blame and fixed the test, but
 IMHO the test was correct and the code should be fixed.

 We need to check if the SERVER_NAME is empty or not. I've attached a patch
 in which I check to make sure SERVER_NAME is not empty and if it is empty
 it will resort to using the admin_email address instead. At least this
 mail address should be valid, although it might still fail to deliver the
 email sent due to using a different domain than the server WordPress is
 installed on.

 A much better option might be to allow the user to choose the from email
 address, but apparently this has been considered and at that moment
 considered a bad idea, see https://core.trac.wordpress.org/ticket/23365

--
Ticket URL: <https://core.trac.wordpress.org/ticket/37945>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list