| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* WP Mail |
| 5 |
*/ |
| 6 |
class WeForms_Emailer_WPMail implements WeForms_Mailer_Contract { |
| 7 |
|
| 8 |
/** |
| 9 |
* Send email via wp_mail |
| 10 |
* |
| 11 |
* @param string $to Email addresses to send message |
| 12 |
* @param string $subject Email subject |
| 13 |
* @param string $body Message contents |
| 14 |
* @param array $headers Optional. Files to attach. |
| 15 |
* |
| 16 |
* @return bool |
| 17 |
*/ |
| 18 |
public function send( $to, $subject, $body, $headers ) { |
| 19 |
$_headers = array(); |
| 20 |
|
| 21 |
if ( isset( $headers['from'] ) ) { |
| 22 |
$_headers[] = sprintf( 'From: %s <%s>', $headers['from']['name'], $headers['from']['email'] ); |
| 23 |
} |
| 24 |
|
| 25 |
if ( isset( $headers['cc'] ) ) { |
| 26 |
$_headers[] = sprintf( 'CC: %s', $headers['cc'] ); |
| 27 |
} |
| 28 |
|
| 29 |
if ( isset( $headers['bcc'] ) ) { |
| 30 |
$_headers[] = sprintf( 'BCC: %s', $headers['bcc'] ); |
| 31 |
} |
| 32 |
|
| 33 |
if ( isset( $headers['replyto'] ) ) { |
| 34 |
$_headers[] = sprintf( 'Reply-To: %s', $headers['replyto'] ); |
| 35 |
} |
| 36 |
|
| 37 |
$_headers[] = 'Content-Type: text/html; charset=UTF-8'; |
| 38 |
|
| 39 |
return wp_mail( $to, $subject, $body, $_headers ); |
| 40 |
} |
| 41 |
} |