Opened 10 years ago
Closed 10 years ago
#38161 closed defect (bug) (duplicate)
wp_mail() fails when run from wp-cli
| Reported by: | desmith | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Version: | ||
| Severity: | normal | Keywords: | has-patch needs-testing |
| Cc: | Focuses: |
Description
In wp-includes/pluggable.php, lines 324-332, wp_mail() handles the case where no From: header is provided to an email, by attempting to create one (wordpress@domain).
The domain is determined by looking at $_SERVER['SERVER_NAME'], which fails when wp_mail is called outside of the context of a Web server (i.e. if called from a wp-cli script).
Using something like substr( home_url( '', 'http'),7) might be a suitable substitute when $_SERVER is unavailable. (If there's a better way to get a site's hostname than slicing up home_url() that of course would work too.)
Attachments (1)
Change History (4)
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
First stab at patch for 38161