WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#9284 closed defect (bug) (fixed)

wp_mail function does not properly process headers array

Reported by: gortsleigh Owned by:
Milestone: 2.8 Priority: normal
Severity: normal Version: 2.7.1
Component: Mail Keywords: has-patch tested
Focuses: Cc:

Description

wp_admin is supposed to accept mail headers either as a string or as an array, but if an array is specified the headers are processed differently than if a string is specified.

The fix is below.

Index: pluggable.php
===================================================================
--- pluggable.php       (revision 10712)
+++ pluggable.php       (working copy)
@@ -275,10 +275,14 @@
        // Headers
        if ( empty( $headers ) ) {
                $headers = array();
-       } elseif ( !is_array( $headers ) ) {
-               // Explode the headers out, so this function can take both
-               // string headers and an array of headers.
-               $tempheaders = (array) explode( "\n", $headers );
+       } else {
+               if ( !is_array( $headers ) ) {
+                       // Explode the headers out, so this function can take either
+                       // string headers or an array of headers.
+                       $tempheaders = (array) explode( "\n", $headers );
+               } else {
+                       $tempheaders = $headers;
+               }
                $headers = array();
 
                // If it's actually got contents

Change History (3)

comment:1 Viper007Bond5 years ago

  • Keywords has-patch added; wp_mail mail removed

comment:2 Denis-de-Bernardy5 years ago

  • Keywords tested added
  • Milestone changed from Unassigned to 2.8

comment:3 ryan5 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [10967]) Fix headers array processing for wp_mail(). Props gortsleigh. fixes #9284

Note: See TracTickets for help on using tickets.