Ticket #5204: email_fix.diff
| File email_fix.diff, 2.2 KB (added by filosofo, 6 years ago) |
|---|
-
wp-includes/pluggable.php
156 156 if ( !empty( $tempheaders ) ) { 157 157 // Iterate through the raw headers 158 158 foreach ( $tempheaders as $header ) { 159 if ( strpos($header, ':') === false ) 159 if ( strpos($header, ':') === false ) { 160 if ( false !== stripos( $header, 'boundary=' ) ) { 161 $header = str_replace('BOUNDARY', 'boundary', $header); 162 $parts = explode('boundary=', trim( $header ) ); 163 $boundary = trim( str_replace( array( '\'', '"' ), '', $parts[1] ) ); 164 } 160 165 continue; 166 } 161 167 // Explode them out 162 168 list( $name, $content ) = explode( ':', trim( $header ), 2 ); 163 169 … … 183 189 if ( strpos( $content,';' ) !== false ) { 184 190 list( $type, $charset ) = explode( ';', $content ); 185 191 $content_type = trim( $type ); 186 $charset = trim( str_replace( array( 'charset=', '"' ), '', $charset ) ); 192 if ( false !== stripos( $charset, 'charset=' ) ) { 193 $charset = trim( str_replace( array( 'charset=', '"' ), '', $charset ) ); 194 } elseif ( false !== stripos( $charset, 'boundary=' ) ) { 195 $boundary = trim( str_replace( array( 'BOUNDARY=', 'boundary=', '"' ), '', $charset ) ); 196 $charset = ''; 197 } 187 198 } else { 188 199 $content_type = trim( $content ); 189 200 } … … 243 254 244 255 $content_type = apply_filters( 'wp_mail_content_type', $content_type ); 245 256 257 $phpmailer->ContentType = $content_type; 258 246 259 // Set whether it's plaintext or not, depending on $content_type 247 260 if ( $content_type == 'text/html' ) { 248 261 $phpmailer->IsHTML( true ); 249 } else { 250 $phpmailer->IsHTML( false ); 251 } 262 } 252 263 253 264 // If we don't have a charset from the input headers 254 265 if ( !isset( $charset ) ) { … … 263 274 foreach ( $headers as $name => $content ) { 264 275 $phpmailer->AddCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) ); 265 276 } 277 if ( false !== stripos( $content_type, 'multipart' ) && ! empty($boundary) ) { 278 $phpmailer->AddCustomHeader( sprintf( "Content-Type: %s;\n\t boundary=\"%s\"", $content_type, $boundary ) ); 279 } 266 280 } 267 281 268 282 do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );
