-
Notifications
You must be signed in to change notification settings - Fork 1
/
SesMailer_body.php
49 lines (45 loc) · 1.2 KB
/
SesMailer_body.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
<?php
class SesMailer {
public static function wfSesMailer($headers, $to, $from, $subject, $body) {
global $wgSesMailerRegion, $wgSesMailerKey, $wgSesMailerSecret;
if (file_exists( __DIR__ . '/vendor/autoload.php')) {
require_once __DIR__ . '/vendor/autoload.php';
}
$ses_factory_array = array(
'version' => 'latest',
'region' => $wgSesMailerRegion,
'credentials' => array(
'key' => $wgSesMailerKey,
'secret' => $wgSesMailerSecret,
)
);
$client = Aws\Ses\SesClient::factory($ses_factory_array);
$param = array();
$param['Source'] = (string)$from;
$param['Destination'] = array(
'ToAddresses' => array(),
);
foreach($to as $recipient) {
$param['Destination']['ToAddresses'][] = (string)$recipient;
}
$param['Message'] = array(
'Subject' => array(
'Data' => $subject,
'Charset' => 'utf-8',
),
'Body' => array(
'Text' => array(
'Data' => $body,
'Charset' => 'utf-8',
),
),
);
try {
$result = $client->sendEmail($param);
return false;
}
catch(Exception $e) {
return "Error sending email: $e";
}
}
}