-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
ses.js
52 lines (42 loc) · 1.17 KB
/
ses.js
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
'use strict';
let nodemailer = require('../lib/nodemailer');
let aws = require('@aws-sdk/client-ses');
/* --- Change these values to test --- */
const AWS_ACCESS_KEY_ID = 'access-key';
const AWS_SECRET_ACCESS_KEY = 'access-secret';
const FROM_ADDRESS = 'andris.reinman@gmail.com';
const TO_ADDRESS = 'andris@kreata.ee';
/* --- no need to change below this line when testing --- */
const ses = new aws.SES({
apiVersion: '2010-12-01',
region: 'us-east-1',
credentials: {
secretAccessKey: AWS_SECRET_ACCESS_KEY,
accessKeyId: AWS_ACCESS_KEY_ID
}
});
// create Nodemailer SES transporter
let transporter = nodemailer.createTransport({
SES: { ses, aws }
});
// send some mail
transporter.sendMail(
{
from: FROM_ADDRESS,
to: TO_ADDRESS,
subject: 'Message ✓ ' + Date.now(),
text: 'I hope this message gets sent! ✓',
ses: {
// optional extra arguments for SendRawEmail
Tags: [
{
Name: 'tag_name',
Value: 'tag_value'
}
]
}
},
(err, info) => {
console.log(err || info);
}
);