36 lines
929 B
PHP
36 lines
929 B
PHP
<?php
|
|
|
|
namespace App\Email;
|
|
|
|
use Mailjet\Client;
|
|
use Mailjet\Resources;
|
|
|
|
class MailjetMailer implements Emailer
|
|
{
|
|
public function __construct(
|
|
private Client $mailjet,
|
|
private string $fromName,
|
|
) {}
|
|
public function send(string $from, string $to, string $body): void
|
|
{
|
|
$this->mailjet->post(Resources::$Email, [
|
|
'body' => [
|
|
'Messages' => [
|
|
[
|
|
'From' => [
|
|
'Email' => $from,
|
|
'Name' => $this->fromName,
|
|
],
|
|
'To' => [
|
|
[
|
|
'Email' => $to,
|
|
],
|
|
],
|
|
'Subject' => 'TIDE',
|
|
'TextPart' => $body,
|
|
],
|
|
],
|
|
],
|
|
]);
|
|
}
|
|
}
|