Changeset 13456
- Timestamp:
- 02/27/2010 04:10:45 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/pluggable.php
r13432 r13456 245 245 * @ 246 246 * 247 * @param string $to Email address to send message247 * @param string|array $to Array or comma-separated list of email addresses to send message. 248 248 * @param string $subject Email subject 249 249 * @param string $message Message contents … … 257 257 258 258 if ( !is_array($attachments) ) 259 $attachments = explode( "\n", $attachments);259 $attachments = explode( "\n", str_replace( "\r\n", "\n", $attachments ) ); 260 260 261 261 global $phpmailer; … … 275 275 // Explode the headers out, so this function can take both 276 276 // string headers and an array of headers. 277 $tempheaders = (array) explode( "\n", $headers);277 $tempheaders = explode( "\n", str_replace( "\r\n", "\n", $headers ) ); 278 278 } else { 279 279 $tempheaders = $headers; … … 296 296 297 297 // Cleanup crew 298 $name = trim( $name);298 $name = trim( $name ); 299 299 $content = trim( $content ); 300 300 301 // Mainly for legacy -- process a From: header if it's there 302 if ( 'from' == strtolower($name) ) { 303 if ( strpos($content, '<' ) !== false ) { 304 // So... making my life hard again? 305 $from_name = substr( $content, 0, strpos( $content, '<' ) - 1 ); 306 $from_name = str_replace( '"', '', $from_name ); 307 $from_name = trim( $from_name ); 308 309 $from_email = substr( $content, strpos( $content, '<' ) + 1 ); 310 $from_email = str_replace( '>', '', $from_email ); 311 $from_email = trim( $from_email ); 312 } else { 313 $from_email = trim( $content ); 314 } 315 } elseif ( 'content-type' == strtolower($name) ) { 316 if ( strpos( $content,';' ) !== false ) { 317 list( $type, $charset ) = explode( ';', $content ); 318 $content_type = trim( $type ); 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 = ''; 301 switch ( strtolower( $name ) ) { 302 // Mainly for legacy -- process a From: header if it's there 303 case 'from': 304 if ( strpos($content, '<' ) !== false ) { 305 // So... making my life hard again? 306 $from_name = substr( $content, 0, strpos( $content, '<' ) - 1 ); 307 $from_name = str_replace( '"', '', $from_name ); 308 $from_name = trim( $from_name ); 309 310 $from_email = substr( $content, strpos( $content, '<' ) + 1 ); 311 $from_email = str_replace( '>', '', $from_email ); 312 $from_email = trim( $from_email ); 313 } else { 314 $from_email = trim( $content ); 324 315 } 325 } else { 326 $content_type = trim( $content ); 327 } 328 } elseif ( 'cc' == strtolower($name) ) { 329 $cc = explode(",", $content); 330 } elseif ( 'bcc' == strtolower($name) ) { 331 $bcc = explode(",", $content); 332 } else { 333 // Add it to our grand headers array 334 $headers[trim( $name )] = trim( $content ); 316 break; 317 case 'content-type': 318 if ( strpos( $content, ';' ) !== false ) { 319 list( $type, $charset ) = explode( ';', $content ); 320 $content_type = trim( $type ); 321 if ( false !== stripos( $charset, 'charset=' ) ) { 322 $charset = trim( str_replace( array( 'charset=', '"' ), '', $charset ) ); 323 } elseif ( false !== stripos( $charset, 'boundary=' ) ) { 324 $boundary = trim( str_replace( array( 'BOUNDARY=', 'boundary=', '"' ), '', $charset ) ); 325 $charset = ''; 326 } 327 } else { 328 $content_type = trim( $content ); 329 } 330 break; 331 case 'cc': 332 $cc = array_merge( (array) $cc, explode( ',', $content ) ); 333 break; 334 case 'bcc': 335 $bcc = array_merge( (array) $bcc, explode( ',', $content ) ); 336 break; 337 default: 338 // Add it to our grand headers array 339 $headers[trim( $name )] = trim( $content ); 340 break; 335 341 } 336 342 } … … 349 355 // From email and name 350 356 // If we don't have a name from the input headers 351 if ( !isset( $from_name ) ) {357 if ( !isset( $from_name ) ) 352 358 $from_name = 'WordPress'; 353 }354 359 355 360 /* If we don't have an email from the input headers default to wordpress@$sitename … … 371 376 372 377 // Plugin authors can override the potentially troublesome default 373 $phpmailer->From = apply_filters( 'wp_mail_from', $from_email ); 374 $phpmailer->FromName = apply_filters( 'wp_mail_from_name', $from_name ); 375 376 // Set destination address 377 $phpmailer->AddAddress( $to ); 378 $phpmailer->From = apply_filters( 'wp_mail_from' , $from_email ); 379 $phpmailer->FromName = apply_filters( 'wp_mail_from_name', $from_name ); 380 381 // Set destination addresses 382 if ( !is_array( $to ) ) 383 $to = explode( ',', $to ); 384 385 foreach ( (array) $to as $recipient ) { 386 $phpmailer->AddAddress( trim( $recipient ) ); 387 } 378 388 379 389 // Set mail's subject and body 380 390 $phpmailer->Subject = $subject; 381 $phpmailer->Body = $message;391 $phpmailer->Body = $message; 382 392 383 393 // Add any CC and BCC recipients 384 if ( !empty( $cc) ) {394 if ( !empty( $cc ) ) { 385 395 foreach ( (array) $cc as $recipient ) { 386 396 $phpmailer->AddCc( trim($recipient) ); 387 397 } 388 398 } 389 if ( !empty($bcc) ) { 399 400 if ( !empty( $bcc ) ) { 390 401 foreach ( (array) $bcc as $recipient) { 391 402 $phpmailer->AddBcc( trim($recipient) ); … … 398 409 // Set Content-Type and charset 399 410 // If we don't have a content-type from the input headers 400 if ( !isset( $content_type ) ) {411 if ( !isset( $content_type ) ) 401 412 $content_type = 'text/plain'; 402 }403 413 404 414 $content_type = apply_filters( 'wp_mail_content_type', $content_type ); … … 407 417 408 418 // Set whether it's plaintext, depending on $content_type 409 if ( $content_type == 'text/html' ) {419 if ( 'text/html' == $content_type ) 410 420 $phpmailer->IsHTML( true ); 411 }412 421 413 422 // If we don't have a charset from the input headers 414 if ( !isset( $charset ) ) {423 if ( !isset( $charset ) ) 415 424 $charset = get_bloginfo( 'charset' ); 416 }417 425 418 426 // Set the content-type and charset … … 424 432 $phpmailer->AddCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) ); 425 433 } 426 if ( false !== stripos( $content_type, 'multipart' ) && ! empty($boundary) ) { 434 435 if ( false !== stripos( $content_type, 'multipart' ) && ! empty($boundary) ) 427 436 $phpmailer->AddCustomHeader( sprintf( "Content-Type: %s;\n\t boundary=\"%s\"", $content_type, $boundary ) ); 428 }429 437 } 430 438
Note: See TracChangeset
for help on using the changeset viewer.