352 | | $phpmailer->setFrom( $from_email, $from_name, false ); |
| 352 | try { |
| 353 | $phpmailer->setFrom( $from_email, $from_name, false ); |
| 354 | } catch ( phpmailerException $e ) { |
| 355 | $mail_error_data = compact( 'to', 'subject', 'message', 'headers', 'attachments' ); |
| 356 | $mail_error_data['phpmailer_exception_code'] = $e->getCode(); |
| 357 | |
| 358 | /** This filter is documented in wp-includes/pluggable.php */ |
| 359 | do_action( 'wp_mail_failed', new WP_Error( 'wp_mail_failed', $e->getMessage(), $mail_error_data ) ); |
| 360 | |
| 361 | return false; |
| 362 | } |
353 | 363 | |
354 | 364 | // Set destination addresses |
355 | 365 | if ( !is_array( $to ) ) |
356 | 366 | $to = explode( ',', $to ); |
357 | 367 | |
358 | 368 | // Set mail's subject and body |
359 | 369 | $phpmailer->Subject = $subject; |
360 | 370 | $phpmailer->Body = $message; |
361 | 371 | |
362 | 372 | // Use appropriate methods for handling addresses, rather than treating them as generic headers |
363 | 373 | $address_headers = compact( 'to', 'cc', 'bcc', 'reply_to' ); |
364 | 374 | |
365 | 375 | foreach ( $address_headers as $address_header => $addresses ) { |
366 | 376 | if ( empty( $addresses ) ) { |
367 | 377 | continue; |