-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
33 lines (29 loc) · 1021 Bytes
/
index.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
var webpipes = require('node-webpipe');
var nodemailer = require('nodemailer');
// Configure the Mail
var mail = nodemailer.createTransport('SES', {
AWSAccessKeyID: process.env['SES_ACCESS_KEY_ID'],
AWSSecretKey: process.env['SES_SECRET_ACCESS_KEY']
});
var block = new webpipes.Block()
.name("Send Email")
.description("WebPipe block for sending emails.")
.input("to", "string", "The email address of the message's recipient.")
.input("subject", "string", "A brief summary of the topic of the message.")
.input("body", "string", "The main content of the message.")
block.handle(function(inputs, callback) {
var options = {
from: process.env['EMAIL_FROM'] || 'WebPipe Action <[email protected]>',
to: inputs.to,
subject: inputs.subject,
text: inputs.body,
};
mail.sendMail(options, function (error, res) {
if (error) {
callback(error);
} else {
callback(null, {});
}
});
});
block.listen();