-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mail.php
52 lines (48 loc) · 1.31 KB
/
Mail.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
declare(strict_types=1);
namespace Ilyamur\PhpMvc\Service;
use Mailjet\Resources;
use Mailjet\Client;
/**
* Mail
*
* PHP version 8.0
*/
class Mail
{
/**
* Send a message
*
* @param string $to Recipient
* @param string $subject Subject
* @param string $text Text-only content of the message
* @param string $html HTML content of the message
* @param string $text Recipient name
*
* @return void
*/
public static function send(string $to, string $subject, string $text, string $html, string $name): void
{
$mj = new Client($_ENV['MJ_APIKEY_PUBLIC'], $_ENV['MJ_APIKEY_PRIVATE'], true, ['version' => 'v3.1']);
$body = [
'Messages' => [
[
'From' => [
'Email' => "ilyamur@hotmail.com",
'Name' => "myPosts App"
],
'To' => [
[
'Email' => $to,
'Name' => $name
]
],
'Subject' => $subject,
'TextPart' => $text,
'HTMLPart' => $html
]
]
];
$mj->post(Resources::$Email, ['body' => $body]);
}
}