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