Make WordPress Core

Changeset 46115


Ignore:
Timestamp:
09/14/2019 08:13:37 PM (7 years ago)
Author:
SergeyBiryukov
Message:

Mail: Avoid setting duplicate MIME-Version and X-Mailer headers in wp_mail(), they are added automatically by PHPMailer.

Props lbenicio, junktrunk, danieltj, studyboi, bennemann.
Fixes #43542.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/pluggable.php

    r45971 r46115  
    451451                $phpmailer->CharSet = apply_filters( 'wp_mail_charset', $charset );
    452452
    453                 // Set custom headers
     453                // Set custom headers.
    454454                if ( ! empty( $headers ) ) {
    455455                        foreach ( (array) $headers as $name => $content ) {
    456                                 $phpmailer->addCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) );
     456                                // Only add custom headers not added automatically by PHPMailer.
     457                                if ( ! in_array( $name, array( 'MIME-Version', 'X-Mailer') ) ) {
     458                                        $phpmailer->addCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) );
     459                                }
    457460                        }
    458461
Note: See TracChangeset for help on using the changeset viewer.