#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 | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Keywords: | ||
Focuses: | Cc: |
Description (last modified by )
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 #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)
Change History (5)
#2
@
8 years ago
- Milestone Awaiting Review deleted
- Resolution set to duplicate
- Status changed from new to closed
- Version trunk deleted
#3
@
8 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.
Thanks for the report, we're already tracking this issue in #25239.