WordPress.org

Make WordPress Core

Ticket #43542: .diff

File .diff, 867 bytes (added by bennemann, 15 months ago)

Patch for preventing to set multiple headers

  • src/wp-includes/pluggable.php

    diff --git a/src/wp-includes/pluggable.php b/src/wp-includes/pluggable.php
    index 9936858ef7..1360f9849d 100644
    a b function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() 
    456456                // Set custom headers
    457457                if ( ! empty( $headers ) ) {
    458458                        foreach ( (array) $headers as $name => $content ) {
    459                                 $phpmailer->addCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) );
     459                                // Only add a custom header if the header is not automagically added from
     460                                // /wp-includes/class-phpmailer.php
     461                                if ( 'MIME-Type' !== $name && 'X-Mailer' !== $name && empty( get_header( $name ) ) ) {
     462                                        $phpmailer->addCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) );       
     463                                }
    460464                        }
    461465
    462466                        if ( false !== stripos( $content_type, 'multipart' ) && ! empty( $boundary ) ) {