Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#37945 closed defect (bug) (duplicate)

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

Reported by: bjornw's profile BjornW Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Mail Keywords:
Focuses: Cc:

Description (last modified by ocean90)

In some WordPress server setups the $_SERVER['SERVER_NAME'] may not have been setup, so $_SERVER['SERVER_NAME'] is empty.

For example Nginx (see 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 #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 #23365.

Attachments (2)

37945.patch (762 bytes) - added by BjornW 7 years ago.
37945.2.patch (512 bytes) - added by BjornW 7 years ago.

Download all attachments as: .zip

Change History (5)

7 years ago

#1 @ocean90
7 years ago

  • Description modified (diff)

7 years ago

#2 @ocean90
7 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
  • Version trunk deleted

Thanks for the report, we're already tracking this issue in #25239.

#3 @BjornW
7 years ago

@ocean90 thanks for cleaning up my description and pointing out the parent issue.

For completeness sake I'd like to add that if the From header is set explicitly the problem described in this issue will not arise.

I've made a small plugin which explicitly sets the admin_email as the From address (with the From name WordPress). In my case this solved my problem for now.

Last edited 7 years ago by BjornW (previous) (diff)
Note: See TracTickets for help on using tickets.