Make WordPress Core

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: Mail 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)

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

Download all attachments as: .zip

Change History (4)

#1 @desmith
10 years ago

  • Severity normalminor

@desmith
10 years ago

First stab at patch for 38161

#2 @desmith
10 years ago

  • Keywords has-patch needs-testing added

#3 @ocean90
10 years ago

  • Milestone Awaiting Review
  • Resolutionduplicate
  • Severity minornormal
  • Status newclosed
  • Version 4.6.1

Hello @desmith, welcome to our Trac!

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

Related: https://github.com/wp-cli/wp-cli/issues/3374

Note: See TracTickets for help on using tickets.