Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#38161 closed defect (bug) (duplicate)

wp_mail() fails when run from wp-cli

Reported by: desmith's profile desmith Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Mail Keywords: has-patch needs-testing
Focuses: Cc:


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)

38161.patch (556 bytes) - added by desmith 7 years ago.
First stab at patch for 38161

Download all attachments as: .zip

Change History (4)

#1 @desmith
7 years ago

  • Severity changed from normal to minor

7 years ago

First stab at patch for 38161

#2 @desmith
7 years ago

  • Keywords has-patch needs-testing added

#3 @ocean90
7 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Severity changed from minor to normal
  • Status changed from new to closed
  • Version 4.6.1 deleted

Hello @desmith, welcome to our Trac!

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


Note: See TracTickets for help on using tickets.