Make WordPress Core


Ignore:
Timestamp:
04/30/2009 07:25:47 AM (17 years ago)
Author:
westi
Message:

Fix wp_mails handling of custom boundaries. Fixes #5204 props filosofo.

File:
1 edited

Legend:

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

    r11109 r11136  
    285285            // Iterate through the raw headers
    286286            foreach ( (array) $tempheaders as $header ) {
    287                 if ( strpos($header, ':') === false )
     287                if ( strpos($header, ':') === false ) {
     288                    if ( false !== stripos( $header, 'boundary=' ) ) {
     289                        $parts = preg_split('/boundary=/i', trim( $header ) );
     290                        $boundary = trim( str_replace( array( "'", '"' ), '', $parts[1] ) );
     291                    }
    288292                    continue;
     293                }
    289294                // Explode them out
    290295                list( $name, $content ) = explode( ':', trim( $header ), 2 );
     
    312317                        list( $type, $charset ) = explode( ';', $content );
    313318                        $content_type = trim( $type );
    314                         $charset = trim( str_replace( array( 'charset=', '"' ), '', $charset ) );
     319                        if ( false !== stripos( $charset, 'charset=' ) ) {
     320                            $charset = trim( str_replace( array( 'charset=', '"' ), '', $charset ) );
     321                        } elseif ( false !== stripos( $charset, 'boundary=' ) ) {
     322                            $boundary = trim( str_replace( array( 'BOUNDARY=', 'boundary=', '"' ), '', $charset ) );
     323                            $charset = '';
     324                        }
    315325                    } else {
    316326                        $content_type = trim( $content );
     
    394404    $content_type = apply_filters( 'wp_mail_content_type', $content_type );
    395405
     406    $phpmailer->ContentType = $content_type;
     407
    396408    // Set whether it's plaintext or not, depending on $content_type
    397409    if ( $content_type == 'text/html' ) {
    398410        $phpmailer->IsHTML( true );
    399     } else {
    400         $phpmailer->IsHTML( false );
    401411    }
    402412
     
    413423        foreach( (array) $headers as $name => $content ) {
    414424            $phpmailer->AddCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) );
     425        }
     426        if ( false !== stripos( $content_type, 'multipart' ) && ! empty($boundary) ) {
     427            $phpmailer->AddCustomHeader( sprintf( "Content-Type: %s;\n\t boundary=\"%s\"", $content_type, $boundary ) );
    415428        }
    416429    }
Note: See TracChangeset for help on using the changeset viewer.