Changeset 38058 for trunk/src/wp-includes/pluggable.php
- Timestamp:
- 07/13/2016 06:03:52 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/pluggable.php
r38028 r38058 217 217 218 218 // Headers 219 $cc = $bcc = $reply_to = array(); 220 219 221 if ( empty( $headers ) ) { 220 222 $headers = array(); … … 228 230 } 229 231 $headers = array(); 230 $cc = array();231 $bcc = array();232 232 233 233 // If it's actually got contents … … 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 … … 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 /** … … 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 … … 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 ) { 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; 368 } 369 370 foreach ( (array) $addresses as $address ) { 376 371 try { 377 372 // Break $recipient into name and address parts if in the format "Foo <bar@baz.com>" 378 373 $recipient_name = ''; 379 if ( preg_match( '/(.*)<(.+)>/', $recipient, $matches ) ) { 374 375 if ( preg_match( '/(.*)<(.+)>/', $address, $matches ) ) { 380 376 if ( count( $matches ) == 3 ) { 381 377 $recipient_name = $matches[1]; 382 $ recipient= $matches[2];378 $address = $matches[2]; 383 379 } 384 380 } 385 $phpmailer->AddCc( $recipient, $recipient_name ); 386 } catch ( phpmailerException $e ) { 387 continue; 388 } 389 } 390 } 391 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]; 401 } 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; 402 395 } 403 $phpmailer->AddBcc( $recipient, $recipient_name );404 396 } catch ( phpmailerException $e ) { 405 397 continue;
Note: See TracChangeset
for help on using the changeset viewer.