-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKMailSender.php
65 lines (38 loc) · 1.69 KB
/
KMailSender.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
53
54
55
56
57
58
59
60
61
62
63
64
<?php
namespace kmailTools;
use Mailjet\Resources;
require_once "mailjet/" . 'vendor/autoload.php';
require_once 'kmailTools/KMailTool.php';
class KMailSender extends KMailTool
{
/*
private $apikey;
private $apisecret;
function __construct($apiKey,$apiSecret)
{
$this->apikey = $apiKey;
$this->apisecret = $apiSecret;
}*/
function sendEMail($sender_Email,$recipientList_array,$content_String,$emailInfo = [])
{
KLog::Create()->logArrayAsJSON($recipientList_array);
$recipientList_array = [$recipientList_array];
KLog::Create()->log("body bout to be created");
$body = [
'FromEmail' => $sender_Email,//"[email protected]",
'FromName' => $this->projectName." - Contact",
'Subject' => "Message from contact form",
'Text-part' => "This is to inform that a message was sent from the contact form:".json_encode($emailInfo),
'Html-part' => "
<h3>This is to inform that a message was sent from the contact form:</h3>
".$content_String ,
'Recipients' =>$recipientList_array
];
KLog::Create()->log("body created");
KLog::Create()->logArrayAsJSON($body);
$mj = new \Mailjet\Client($this->apikey, $this->apisecret);
$response = $mj->post(Resources::$Email, ['body' => $body]);
$response->success() && $this->showDataPretty($response->getData());
KLog::Create()->log( $response->getStatus());
}
}