1 | "use strict";
|
2 |
|
3 | const EmailSender = require('./EmailSender');
|
4 | const AWS = require('aws-sdk');
|
5 | const callback = require('../helper/callback');
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | class SESEmailSender extends EmailSender
|
13 | {
|
14 | constructor(region)
|
15 | {
|
16 | super();
|
17 | AWS.config.update({
|
18 | region
|
19 | });
|
20 | this.ses = new AWS.SES({
|
21 | apiVersion: '2010-12-01'
|
22 | });
|
23 | }
|
24 |
|
25 | sendImplementation(to, from, subject, body)
|
26 | {
|
27 | const packet = {
|
28 | Source: from,
|
29 | Destination: {
|
30 | ToAddresses: [to]
|
31 | },
|
32 | Message: {
|
33 | Subject: {
|
34 | Data: subject
|
35 | },
|
36 | Body: {
|
37 | Html: {
|
38 | Data: body,
|
39 | }
|
40 | }
|
41 | }
|
42 | };
|
43 |
|
44 |
|
45 | return callback(this.ses.sendEmail.bind(this.ses), packet);
|
46 | }
|
47 | }
|
48 |
|
49 | module.exports = SESEmailSender;
|