diff --git src/wp-includes/pluggable.php src/wp-includes/pluggable.php
index 8b64359..68c9148 100644
|
|
|
function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() |
| 227 | 227 | $tempheaders = $headers; |
| 228 | 228 | } |
| 229 | 229 | $headers = array(); |
| 230 | | $cc = array(); |
| 231 | | $bcc = array(); |
| | 230 | $cc = $bcc = $reply_to = array(); |
| 232 | 231 | |
| 233 | 232 | // If it's actually got contents |
| 234 | 233 | if ( !empty( $tempheaders ) ) { |
| … |
… |
function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() |
| 286 | 285 | } |
| 287 | 286 | break; |
| 288 | 287 | case 'cc': |
| 289 | | $cc = array_merge( (array) $cc, explode( ',', $content ) ); |
| 290 | | break; |
| 291 | 288 | case 'bcc': |
| 292 | | $bcc = array_merge( (array) $bcc, explode( ',', $content ) ); |
| | 289 | case 'reply-to': |
| | 290 | // Update the existing variable (e.g., $cc, $bcc, $reply_to) from the passed header |
| | 291 | $header_variable = str_replace( '-', '_', strtolower( $name ) ); |
| | 292 | $$header_variable = array_merge( (array) $$header_variable, explode( ',', $content ) ); |
| 293 | 293 | break; |
| 294 | 294 | default: |
| 295 | 295 | // Add it to our grand headers array |
| … |
… |
function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() |
| 335 | 335 | * |
| 336 | 336 | * @param string $from_email Email address to send from. |
| 337 | 337 | */ |
| 338 | | $phpmailer->From = apply_filters( 'wp_mail_from', $from_email ); |
| | 338 | $from_email = apply_filters( 'wp_mail_from', $from_email ); |
| 339 | 339 | |
| 340 | 340 | /** |
| 341 | 341 | * Filters the name to associate with the "from" email address. |
| … |
… |
function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() |
| 344 | 344 | * |
| 345 | 345 | * @param string $from_name Name associated with the "from" email address. |
| 346 | 346 | */ |
| 347 | | $phpmailer->FromName = apply_filters( 'wp_mail_from_name', $from_name ); |
| | 347 | $from_name = apply_filters( 'wp_mail_from_name', $from_name ); |
| | 348 | |
| | 349 | $phpmailer->setFrom( $from_email, $from_name ); |
| 348 | 350 | |
| 349 | 351 | // Set destination addresses |
| 350 | 352 | if ( !is_array( $to ) ) |
| 351 | 353 | $to = explode( ',', $to ); |
| 352 | 354 | |
| 353 | | foreach ( (array) $to as $recipient ) { |
| 354 | | try { |
| 355 | | // Break $recipient into name and address parts if in the format "Foo <bar@baz.com>" |
| 356 | | $recipient_name = ''; |
| 357 | | if ( preg_match( '/(.*)<(.+)>/', $recipient, $matches ) ) { |
| 358 | | if ( count( $matches ) == 3 ) { |
| 359 | | $recipient_name = $matches[1]; |
| 360 | | $recipient = $matches[2]; |
| 361 | | } |
| 362 | | } |
| 363 | | $phpmailer->AddAddress( $recipient, $recipient_name); |
| 364 | | } catch ( phpmailerException $e ) { |
| 365 | | continue; |
| 366 | | } |
| 367 | | } |
| 368 | | |
| 369 | 355 | // Set mail's subject and body |
| 370 | 356 | $phpmailer->Subject = $subject; |
| 371 | 357 | $phpmailer->Body = $message; |
| 372 | 358 | |
| 373 | | // Add any CC and BCC recipients |
| 374 | | if ( !empty( $cc ) ) { |
| 375 | | foreach ( (array) $cc as $recipient ) { |
| 376 | | try { |
| 377 | | // Break $recipient into name and address parts if in the format "Foo <bar@baz.com>" |
| 378 | | $recipient_name = ''; |
| 379 | | if ( preg_match( '/(.*)<(.+)>/', $recipient, $matches ) ) { |
| 380 | | if ( count( $matches ) == 3 ) { |
| 381 | | $recipient_name = $matches[1]; |
| 382 | | $recipient = $matches[2]; |
| 383 | | } |
| 384 | | } |
| 385 | | $phpmailer->AddCc( $recipient, $recipient_name ); |
| 386 | | } catch ( phpmailerException $e ) { |
| 387 | | continue; |
| 388 | | } |
| 389 | | } |
| 390 | | } |
| | 359 | // Use appropriate methods for handling addresses, rather than treating them as generic headers |
| | 360 | $header_method_map = array( |
| | 361 | 'to' => 'AddAddress', |
| | 362 | 'cc' => 'AddCc', |
| | 363 | 'bcc' => 'AddBcc', |
| | 364 | 'reply_to' => 'AddReplyTo' |
| | 365 | ); |
| 391 | 366 | |
| 392 | | if ( !empty( $bcc ) ) { |
| 393 | | foreach ( (array) $bcc as $recipient) { |
| 394 | | try { |
| 395 | | // Break $recipient into name and address parts if in the format "Foo <bar@baz.com>" |
| 396 | | $recipient_name = ''; |
| 397 | | if ( preg_match( '/(.*)<(.+)>/', $recipient, $matches ) ) { |
| 398 | | if ( count( $matches ) == 3 ) { |
| 399 | | $recipient_name = $matches[1]; |
| 400 | | $recipient = $matches[2]; |
| | 367 | foreach ( $header_method_map as $address_header => $address_handler ) { |
| | 368 | if ( ! empty( $$address_header ) ) { |
| | 369 | foreach ( (array) $$address_header as $address ) { |
| | 370 | try { |
| | 371 | // Break $recipient into name and address parts if in the format "Foo <bar@baz.com>" |
| | 372 | $recipient_name = ''; |
| | 373 | |
| | 374 | if ( preg_match( '/(.*)<(.+)>/', $address, $matches ) ) { |
| | 375 | if ( count( $matches ) == 3 ) { |
| | 376 | $recipient_name = $matches[1]; |
| | 377 | $address = $matches[2]; |
| | 378 | } |
| 401 | 379 | } |
| | 380 | |
| | 381 | call_user_func( array( $phpmailer, $address_handler ), $address, $recipient_name ); |
| | 382 | } catch ( phpmailerException $e ) { |
| | 383 | continue; |
| 402 | 384 | } |
| 403 | | $phpmailer->AddBcc( $recipient, $recipient_name ); |
| 404 | | } catch ( phpmailerException $e ) { |
| 405 | | continue; |
| 406 | 385 | } |
| 407 | 386 | } |
| 408 | 387 | } |