Ticket #15448: 15448.diff
File 15448.diff, 4.2 KB (added by , 14 years ago) |
---|
-
pluggable.php
247 247 * However, you can set the content type of the email by using the 248 248 * 'wp_mail_content_type' filter. 249 249 * 250 * If $message is an array, the key of each is used to add as an attachment, 251 * with the value used as the body. The 'text/plain' element is used as the 252 * text version of the body, with the 'text/html' element used as the HTML 253 * version of the body. All other types are added as attachments. 254 * 250 255 * The default charset is based on the charset used on the blog. The charset can 251 256 * be set using the 'wp_mail_charset' filter. 252 257 * … … 263 268 * 264 269 * @param string|array $to Array or comma-separated list of email addresses to send message. 265 270 * @param string $subject Email subject 266 * @param string $message Message contents271 * @param string|array $message Message contents 267 272 * @param string|array $headers Optional. Additional headers. 268 273 * @param string|array $attachments Optional. Files to attach. 269 274 * @return bool Whether the email contents were sent successfully. … … 332 337 } 333 338 break; 334 339 case 'content-type': 340 if ( is_array($message) ) { 341 // Multipart email, ignore the content-type header 342 break; 343 } 335 344 if ( strpos( $content, ';' ) !== false ) { 336 345 list( $type, $charset ) = explode( ';', $content ); 337 346 $content_type = trim( $type ); … … 403 412 $phpmailer->AddAddress( trim( $recipient ) ); 404 413 } 405 414 415 // If we don't have a charset from the input headers 416 if ( !isset( $charset ) ) 417 $charset = get_bloginfo( 'charset' ); 418 419 // Set the content-type and charset 420 $phpmailer->CharSet = apply_filters( 'wp_mail_charset', $charset ); 421 406 422 // Set mail's subject and body 407 423 $phpmailer->Subject = $subject; 408 $phpmailer->Body = $message;409 424 425 if ( is_string($message) ) { 426 $phpmailer->Body = $message; 427 428 // Set Content-Type and charset 429 // If we don't have a content-type from the input headers 430 if ( !isset( $content_type ) ) 431 $content_type = 'text/plain'; 432 433 $content_type = apply_filters( 'wp_mail_content_type', $content_type ); 434 435 $phpmailer->ContentType = $content_type; 436 437 // Set whether it's plaintext, depending on $content_type 438 if ( 'text/html' == $content_type ) 439 $phpmailer->IsHTML( true ); 440 441 // For backwards compatibility, new multipart emails should use 442 // the array style $message. This never really worked well anyway 443 if ( false !== stripos( $content_type, 'multipart' ) && ! empty($boundary) ) 444 $phpmailer->AddCustomHeader( sprintf( "Content-Type: %s;\n\t boundary=\"%s\"", $content_type, $boundary ) ); 445 } 446 elseif ( is_array($message) ) { 447 foreach ($message as $type => $body) { 448 if ($type === 'text/html') { 449 $phpmailer->Body = $body; 450 } 451 elseif ($type === 'text/plain') { 452 $phpmailer->AltBody = $body; 453 } 454 else { 455 $phpmailer->AddAttachment($body, '', 'base64', $type); 456 } 457 } 458 } 459 410 460 // Add any CC and BCC recipients 411 461 if ( !empty( $cc ) ) { 412 462 foreach ( (array) $cc as $recipient ) { … … 423 473 // Set to use PHP's mail() 424 474 $phpmailer->IsMail(); 425 475 426 // Set Content-Type and charset427 // If we don't have a content-type from the input headers428 if ( !isset( $content_type ) )429 $content_type = 'text/plain';430 431 $content_type = apply_filters( 'wp_mail_content_type', $content_type );432 433 $phpmailer->ContentType = $content_type;434 435 // Set whether it's plaintext, depending on $content_type436 if ( 'text/html' == $content_type )437 $phpmailer->IsHTML( true );438 439 // If we don't have a charset from the input headers440 if ( !isset( $charset ) )441 $charset = get_bloginfo( 'charset' );442 443 // Set the content-type and charset444 $phpmailer->CharSet = apply_filters( 'wp_mail_charset', $charset );445 446 476 // Set custom headers 447 477 if ( !empty( $headers ) ) { 448 478 foreach( (array) $headers as $name => $content ) { 449 479 $phpmailer->AddCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) ); 450 480 } 451 452 if ( false !== stripos( $content_type, 'multipart' ) && ! empty($boundary) )453 $phpmailer->AddCustomHeader( sprintf( "Content-Type: %s;\n\t boundary=\"%s\"", $content_type, $boundary ) );454 481 } 455 482 456 483 if ( !empty( $attachments ) ) {