| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentSupport\App\Services; |
| 4 |
|
| 5 |
use FluentSupport\App\App; |
| 6 |
use FluentSupport\Framework\Support\Arr; |
| 7 |
|
| 8 |
class Mailer |
| 9 |
{ |
| 10 |
public static function send($to, $subject, $body, $extraHeader = [], $attachments = []) |
| 11 |
{ |
| 12 |
$headers = self::getHeaders(); |
| 13 |
|
| 14 |
if($extraHeader) { |
| 15 |
foreach ($extraHeader as $header) { |
| 16 |
$headers[] = $header; |
| 17 |
} |
| 18 |
} |
| 19 |
|
| 20 |
return wp_mail($to, $subject, $body, $headers, $attachments); |
| 21 |
} |
| 22 |
|
| 23 |
public static function getHeaders() |
| 24 |
{ |
| 25 |
$headers[] = 'Content-Type: text/html; charset=UTF-8'; |
| 26 |
return $headers; |
| 27 |
} |
| 28 |
|
| 29 |
public static function getWithTemplate($body) |
| 30 |
{ |
| 31 |
$app = App::getInstance(); |
| 32 |
return $app->view->make('emails.classic_template', [ |
| 33 |
'email_body' => $body |
| 34 |
]); |
| 35 |
} |
| 36 |
} |
| 37 |
|