[wp-trac] [WordPress Trac] #38161: wp_mail() fails when run from wp-cli

WordPress Trac noreply at wordpress.org
Mon Sep 26 15:05:59 UTC 2016


#38161: wp_mail() fails when run from wp-cli
--------------------------+-----------------------------
 Reporter:  desmith       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Mail          |    Version:  4.6.1
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 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 at 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.)

--
Ticket URL: <https://core.trac.wordpress.org/ticket/38161>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list