Ticket #15448: 15448_Feb2016.diff
File 15448_Feb2016.diff, 5.1 KB (added by , 9 years ago) |
---|
-
src/wp-includes/pluggable.php
202 202 * However, you can set the content type of the email by using the 203 203 * 'wp_mail_content_type' filter. 204 204 * 205 * If $message is an array, the key of each is used to add as an attachment 206 * with the value used as the body. The 'text/plain' element is used as the 207 * text version of the body, with the 'text/html' element used as the HTML 208 * version of the body. All other types are added as attachments. 209 * 205 210 * The default charset is based on the charset used on the blog. The charset can 206 211 * be set using the 'wp_mail_charset' filter. 207 212 * … … 211 216 * 212 217 * @param string|array $to Array or comma-separated list of email addresses to send message. 213 218 * @param string $subject Email subject 214 * @param string 219 * @param string|array $message Message contents 215 220 * @param string|array $headers Optional. Additional headers. 216 221 * @param string|array $attachments Optional. Files to attach. 217 222 * @return bool Whether the email contents were sent successfully. … … 316 321 } 317 322 break; 318 323 case 'content-type': 324 if ( is_array( $message ) ) { 325 // Multipart email, ignore the content-type header 326 break; 327 } 319 328 if ( strpos( $content, ';' ) !== false ) { 320 329 list( $type, $charset_content ) = explode( ';', $content ); 321 330 $content_type = trim( $type ); … … 352 361 $phpmailer->ClearCustomHeaders(); 353 362 $phpmailer->ClearReplyTos(); 354 363 364 $phpmailer->Body= ''; 365 $phpmailer->AltBody= ''; 366 355 367 // From email and name 356 368 // If we don't have a name from the input headers 357 369 if ( !isset( $from_name ) ) … … 412 424 } 413 425 } 414 426 427 // If we don't have a charset from the input headers 428 if ( ! isset( $charset ) ) 429 $charset = get_bloginfo( 'charset' ); 430 431 // Set the content-type and charset 432 433 /** 434 * Filter the default wp_mail() charset. 435 * 436 * @since 2.3.0 437 * 438 * @param string $charset Default email charset. 439 */ 440 $phpmailer->CharSet = apply_filters( 'wp_mail_charset', $charset ); 441 415 442 // Set mail's subject and body 416 443 $phpmailer->Subject = $subject; 417 $phpmailer->Body = $message;418 444 445 if ( is_string( $message ) ) { 446 $phpmailer->Body = $message; 447 448 // Set Content-Type and charset 449 // If we don't have a content-type from the input headers 450 if ( ! isset( $content_type ) ) { 451 $content_type = 'text/plain'; 452 } 453 454 /** 455 * Filter the wp_mail() content type. 456 * 457 * @since 2.3.0 458 * 459 * @param string $content_type Default wp_mail() content type. 460 */ 461 $content_type = apply_filters( 'wp_mail_content_type', $content_type ); 462 463 $phpmailer->ContentType = $content_type; 464 465 // Set whether it's plaintext, depending on $content_type 466 if ( 'text/html' == $content_type ) { 467 $phpmailer->IsHTML( true ); 468 } 469 470 // For backwards compatibility, new multipart emails should use 471 // the array style $message. This never really worked well anyway 472 if ( false !== stripos( $content_type, 'multipart' ) && ! empty( $boundary ) ) { 473 $phpmailer->AddCustomHeader( sprintf( "Content-Type: %s;\n\t boundary=\"%s\"", $content_type, $boundary ) ); 474 } 475 } elseif ( is_array( $message ) ) { 476 foreach ( $message as $type => $bodies ) { 477 foreach ( (array) $bodies as $body ) { 478 if ( 'text/html' === $type ) { 479 $phpmailer->Body = $body; 480 } elseif ( 'text/plain' === $type ) { 481 $phpmailer->AltBody = $body; 482 } else { 483 $phpmailer->AddAttachment( $body, '', 'base64', $type ); 484 } 485 } 486 } 487 } 488 419 489 // Add any CC and BCC recipients 420 490 if ( !empty( $cc ) ) { 421 491 foreach ( (array) $cc as $recipient ) { … … 456 526 // Set to use PHP's mail() 457 527 $phpmailer->IsMail(); 458 528 459 // Set Content-Type and charset460 // If we don't have a content-type from the input headers461 if ( !isset( $content_type ) )462 $content_type = 'text/plain';463 464 /**465 * Filter the wp_mail() content type.466 *467 * @since 2.3.0468 *469 * @param string $content_type Default wp_mail() content type.470 */471 $content_type = apply_filters( 'wp_mail_content_type', $content_type );472 473 $phpmailer->ContentType = $content_type;474 475 // Set whether it's plaintext, depending on $content_type476 if ( 'text/html' == $content_type )477 $phpmailer->IsHTML( true );478 479 // If we don't have a charset from the input headers480 if ( !isset( $charset ) )481 $charset = get_bloginfo( 'charset' );482 483 // Set the content-type and charset484 485 /**486 * Filter the default wp_mail() charset.487 *488 * @since 2.3.0489 *490 * @param string $charset Default email charset.491 */492 $phpmailer->CharSet = apply_filters( 'wp_mail_charset', $charset );493 494 529 // Set custom headers 495 530 if ( !empty( $headers ) ) { 496 531 foreach ( (array) $headers as $name => $content ) { 497 532 $phpmailer->AddCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) ); 498 533 } 499 500 if ( false !== stripos( $content_type, 'multipart' ) && ! empty($boundary) )501 $phpmailer->AddCustomHeader( sprintf( "Content-Type: %s;\n\t boundary=\"%s\"", $content_type, $boundary ) );502 534 } 503 535 504 536 if ( !empty( $attachments ) ) {