| 1 |
<?php |
| 2 |
|
| 3 |
namespace Getwid; |
| 4 |
|
| 5 |
class Mailer { |
| 6 |
|
| 7 |
public function __construct() { |
| 8 |
} |
| 9 |
|
| 10 |
/** |
| 11 |
* Send an email. |
| 12 |
* @param string|array $to Array or comma-separated list of email addresses to send message. |
| 13 |
* @param string $subject |
| 14 |
* @param string $message |
| 15 |
* @param array|string $headers Optional. Additional headers. |
| 16 |
* @param array|string $attachments Optional. Files to attach. |
| 17 |
* @return bool success |
| 18 |
*/ |
| 19 |
public function send( $to, $subject, $message, $headers = null, $attachments = null ){ |
| 20 |
|
| 21 |
add_filter( 'wp_mail_content_type', array( $this, 'filterContentType' ) ); |
| 22 |
|
| 23 |
$result = wp_mail( $to, $subject, $message, $headers, $attachments ); |
| 24 |
|
| 25 |
remove_filter( 'wp_mail_content_type', array( $this, 'filterContentType' ) ); |
| 26 |
|
| 27 |
return $result; |
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* Filter email content type. |
| 32 |
* |
| 33 |
* @param string $contentType |
| 34 |
* |
| 35 |
* @return string |
| 36 |
*/ |
| 37 |
public function filterContentType( $contentType ){ |
| 38 |
return 'text/html'; |
| 39 |
} |
| 40 |
|
| 41 |
} |
| 42 |
|