[wp-trac] [WordPress Trac] #62211: defect (bug): wp_site_admin_email_change_notification triggers wp_mail with an empty to address creating downstream wp_mail_failed

WordPress Trac noreply at wordpress.org
Sat Oct 12 22:13:04 UTC 2024


#62211: defect (bug): wp_site_admin_email_change_notification triggers wp_mail with
an empty to address creating downstream wp_mail_failed
---------------------------------------+-----------------------------
 Reporter:  spenserhale                |      Owner:  (none)
     Type:  defect (bug)               |     Status:  new
 Priority:  normal                     |  Milestone:  Awaiting Review
Component:  Administration             |    Version:
 Severity:  minor                      |   Keywords:
  Focuses:  administration, multisite  |
---------------------------------------+-----------------------------
 **Issue Summary:**
 The wp_site_admin_email_change_notification function calls wp_mail with an
 empty “to” address when the admin_email option is not set during the site
 creation. This behavior leads to a downstream wp_mail_failed event being
 triggered.

 **Steps to Reproduce:**

         1.      **Create a new site:**

         •       Using multisite, a new site can be created either through
 wp_insert_site() or by direct database inserts.
         •       This creation may occur via CLI commands, API calls,
 backup and restore plugins and more.

         2.      **Update the admin_email option:**

         •       Call update_option('admin_email', 'anyemail at example.com')
 with any valid email address.
         •       Observe that when the admin_email is empty initially,
 wp_mail is called with an empty “to” address, causing wp_mail_failed
 event.


 **Code Example:**
 {{{
 $site_id = wp_insert_site([
 ‘domain’ => ‘example.com’,
 ‘path’ => ‘/’,
 ‘title’ => ‘example’,
 ‘lang_id’ => 1,
 ‘options’ => [‘blog_public’ => 0]
 ]);

 switch_to_blog($site_id);

 update_option(‘admin_email’, ‘new-admin at example.com’);
 }}}

 **Non-Multisite:**
 It also affects single-site installations created without the option, for
 example, using backup plugins where the admin_email option may not be set
 during site restoration.


 **Preferred Behavior:**
 wp_site_admin_email_change_notification should include validation for the
 admin_email field, ensuring it is not empty before invoking wp_mail.

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


More information about the wp-trac mailing list