Ticket #15448: 15448_March2013.diff
File 15448_March2013.diff, 4.5 KB (added by , 12 years ago) |
---|
-
wp-includes/pluggable.php
191 191 * However, you can set the content type of the email by using the 192 192 * 'wp_mail_content_type' filter. 193 193 * 194 * If $message is an array, the key of each is used to add as an attachment 195 * with the value used as the body. The 'text/plain' element is used as the 196 * text version of the body, with the 'text/html' element used as the HTML 197 * version of the body. All other types are added as attachments. 198 * 194 199 * The default charset is based on the charset used on the blog. The charset can 195 200 * be set using the 'wp_mail_charset' filter. 196 201 * … … 206 211 * 207 212 * @param string|array $to Array or comma-separated list of email addresses to send message. 208 213 * @param string $subject Email subject 209 * @param string $message Message contents214 * @param string|array $message Message contents 210 215 * @param string|array $headers Optional. Additional headers. 211 216 * @param string|array $attachments Optional. Files to attach. 212 217 * @return bool Whether the email contents were sent successfully. … … 277 282 } 278 283 break; 279 284 case 'content-type': 285 if ( is_array($message) ) { 286 // Multipart email, ignore the content-type header 287 break; 288 } 280 289 if ( strpos( $content, ';' ) !== false ) { 281 290 list( $type, $charset ) = explode( ';', $content ); 282 291 $content_type = trim( $type ); … … 314 323 $phpmailer->ClearCustomHeaders(); 315 324 $phpmailer->ClearReplyTos(); 316 325 326 $phpmailer->Body= ''; 327 $phpmailer->AltBody= ''; 328 317 329 // From email and name 318 330 // If we don't have a name from the input headers 319 331 if ( !isset( $from_name ) ) … … 360 372 } 361 373 } 362 374 375 // If we don't have a charset from the input headers 376 if ( !isset( $charset ) ) 377 $charset = get_bloginfo( 'charset' ); 378 379 // Set the content-type and charset 380 $phpmailer->CharSet = apply_filters( 'wp_mail_charset', $charset ); 381 363 382 // Set mail's subject and body 364 383 $phpmailer->Subject = $subject; 365 $phpmailer->Body = $message;366 384 367 // Add any CC and BCC recipients 385 if ( is_string($message) ) { 386 $phpmailer->Body = $message; 387 388 // Set Content-Type and charset 389 // If we don't have a content-type from the input headers 390 if ( !isset( $content_type ) ) 391 $content_type = 'text/plain'; 392 393 $content_type = apply_filters( 'wp_mail_content_type', $content_type ); 394 395 $phpmailer->ContentType = $content_type; 396 397 // Set whether it's plaintext, depending on $content_type 398 if ( 'text/html' == $content_type ) 399 $phpmailer->IsHTML( true ); 400 401 // For backwards compatibility, new multipart emails should use 402 // the array style $message. This never really worked well anyway 403 if ( false !== stripos( $content_type, 'multipart' ) && ! empty($boundary) ) 404 $phpmailer->AddCustomHeader( sprintf( "Content-Type: %s;\n\t boundary=\"%s\"", $content_type, $boundary ) ); 405 } 406 elseif ( is_array($message) ) { 407 foreach ($message as $type => $bodies) { 408 foreach ((array) $bodies as $body) { 409 if ($type === 'text/html') { 410 $phpmailer->Body = $body; 411 } 412 elseif ($type === 'text/plain') { 413 $phpmailer->AltBody = $body; 414 } 415 else { 416 $phpmailer->AddAttachment($body, '', 'base64', $type); 417 } 418 } 419 } 420 } 421 422 // Add any CC and BCC recipients 368 423 if ( !empty( $cc ) ) { 369 424 foreach ( (array) $cc as $recipient ) { 370 425 try { … … 404 459 // Set to use PHP's mail() 405 460 $phpmailer->IsMail(); 406 461 407 // Set Content-Type and charset408 // If we don't have a content-type from the input headers409 if ( !isset( $content_type ) )410 $content_type = 'text/plain';411 412 $content_type = apply_filters( 'wp_mail_content_type', $content_type );413 414 $phpmailer->ContentType = $content_type;415 416 // Set whether it's plaintext, depending on $content_type417 if ( 'text/html' == $content_type )418 $phpmailer->IsHTML( true );419 420 // If we don't have a charset from the input headers421 if ( !isset( $charset ) )422 $charset = get_bloginfo( 'charset' );423 424 // Set the content-type and charset425 $phpmailer->CharSet = apply_filters( 'wp_mail_charset', $charset );426 427 462 // Set custom headers 428 463 if ( !empty( $headers ) ) { 429 464 foreach( (array) $headers as $name => $content ) { 430 465 $phpmailer->AddCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) ); 431 466 } 432 433 if ( false !== stripos( $content_type, 'multipart' ) && ! empty($boundary) )434 $phpmailer->AddCustomHeader( sprintf( "Content-Type: %s;\n\t boundary=\"%s\"", $content_type, $boundary ) );435 467 } 436 468 437 469 if ( !empty( $attachments ) ) {