@5minds/node-red-contrib-processcube-tools 1.0.1-feature-f506be-mfe3agh6 → 1.0.1-feature-20a8ee-mff2npts
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/email-receiver/email-receiver.html +187 -0
- package/email-receiver/email-receiver.js +236 -0
- package/package.json +26 -5
- package/test/helpers/email-receiver.mocks.js +421 -0
- package/test/integration/email-receiver.integration.test.js +479 -0
- package/test/unit/email-receiver.unit.test.js +353 -0
- package/email-sender/email-sender.html +0 -257
- package/email-sender/email-sender.js +0 -91
- /package/{processcube-html-to-text/processcube-html-to-text.html → processcube-html-to-text.html} +0 -0
- /package/{processcube-html-to-text/processcube-html-to-text.js → processcube-html-to-text.js} +0 -0
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
module.exports = function(RED) {
|
|
2
|
-
"use strict";
|
|
3
|
-
const nodemailer = require("nodemailer");
|
|
4
|
-
|
|
5
|
-
function EmailSenderNode(config) {
|
|
6
|
-
RED.nodes.createNode(this, config);
|
|
7
|
-
var node = this;
|
|
8
|
-
|
|
9
|
-
node.on('input', function(msg, send, done) {
|
|
10
|
-
send = send || function() { node.send.apply(node, arguments); };
|
|
11
|
-
done = done || function(err) { if (err) node.error(err, msg); };
|
|
12
|
-
|
|
13
|
-
// Retrieve and evaluate mail configuration values
|
|
14
|
-
const sender = RED.util.evaluateNodeProperty(config.sender, config.senderType, node, msg);
|
|
15
|
-
const address = RED.util.evaluateNodeProperty(config.address, config.addressType, node, msg);
|
|
16
|
-
const to = RED.util.evaluateNodeProperty(config.to, config.toType, node, msg);
|
|
17
|
-
const cc = RED.util.evaluateNodeProperty(config.cc, config.ccType, node, msg) || "";
|
|
18
|
-
const bcc = RED.util.evaluateNodeProperty(config.bcc, config.bccType, node, msg) || "";
|
|
19
|
-
const subject = RED.util.evaluateNodeProperty(config.subject, config.subjectType, node, msg) || msg.topic || "Message from Node-RED";
|
|
20
|
-
const attachments = RED.util.evaluateNodeProperty(config.attachments, config.attachmentsType, node, msg);
|
|
21
|
-
const htmlContent = RED.util.evaluateNodeProperty(config.htmlContent, config.htmlContentType, node, msg);
|
|
22
|
-
|
|
23
|
-
// Retrieve and evaluate SMTP configuration values
|
|
24
|
-
const host = RED.util.evaluateNodeProperty(config.host, config.hostType, node, msg);
|
|
25
|
-
const port = RED.util.evaluateNodeProperty(config.port, config.portType, node, msg);
|
|
26
|
-
const user = RED.util.evaluateNodeProperty(config.user, config.userType, node, msg);
|
|
27
|
-
const password = RED.util.evaluateNodeProperty(config.password, config.passwordType, node, msg);
|
|
28
|
-
const secure = RED.util.evaluateNodeProperty(config.secure, config.secureType, node, msg);
|
|
29
|
-
const rejectUnauthorized = RED.util.evaluateNodeProperty(config.rejectUnauthorized, config.rejectUnauthorizedType, node, msg);
|
|
30
|
-
|
|
31
|
-
// Create SMTP transporter
|
|
32
|
-
const transporter = nodemailer.createTransport({
|
|
33
|
-
host: host,
|
|
34
|
-
port: port,
|
|
35
|
-
secure: secure,
|
|
36
|
-
auth: {
|
|
37
|
-
user: user,
|
|
38
|
-
pass: password
|
|
39
|
-
},
|
|
40
|
-
tls: {
|
|
41
|
-
rejectUnauthorized: rejectUnauthorized
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
// Create email object
|
|
46
|
-
const mailOptions = {
|
|
47
|
-
from: {
|
|
48
|
-
name: sender,
|
|
49
|
-
address: address
|
|
50
|
-
},
|
|
51
|
-
to: to,
|
|
52
|
-
cc: cc,
|
|
53
|
-
bcc: bcc,
|
|
54
|
-
subject: subject,
|
|
55
|
-
html: Buffer.from(htmlContent, 'utf-8'),
|
|
56
|
-
attachments: attachments
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
// Send email
|
|
60
|
-
transporter.sendMail(mailOptions, (error, info) => {
|
|
61
|
-
if (error) {
|
|
62
|
-
node.status({ fill: "red", shape: "dot", text: "error sending" });
|
|
63
|
-
done(error);
|
|
64
|
-
} else {
|
|
65
|
-
node.log('Email sent: ' + info.response);
|
|
66
|
-
msg.payload = info;
|
|
67
|
-
|
|
68
|
-
if (msg.payload.accepted && msg.payload.accepted.length > 0) {
|
|
69
|
-
msg.payload = msg.input;
|
|
70
|
-
node.status({ fill: "green", shape: "dot", text: "sent" });
|
|
71
|
-
send(msg);
|
|
72
|
-
done();
|
|
73
|
-
} else if (msg.payload.rejected && msg.payload.rejected.length > 0) {
|
|
74
|
-
msg.error = { result: msg.payload.rejected };
|
|
75
|
-
node.status({ fill: "red", shape: "dot", text: "rejected" });
|
|
76
|
-
done(new Error('Email rejected: ' + msg.payload.rejected.join(', ')));
|
|
77
|
-
} else if (msg.payload.pending && msg.payload.pending.length > 0) {
|
|
78
|
-
msg.error = { result: msg.payload.pending };
|
|
79
|
-
node.status({ fill: "yellow", shape: "dot", text: "pending" });
|
|
80
|
-
done(new Error('Email pending: ' + msg.payload.pending.join(', ')));
|
|
81
|
-
} else {
|
|
82
|
-
node.status({ fill: "red", shape: "dot", text: "unknown error" });
|
|
83
|
-
done(new Error('Unknown error while sending email.'));
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
RED.nodes.registerType("email-sender", EmailSenderNode);
|
|
91
|
-
};
|
/package/{processcube-html-to-text/processcube-html-to-text.html → processcube-html-to-text.html}
RENAMED
|
File without changes
|
/package/{processcube-html-to-text/processcube-html-to-text.js → processcube-html-to-text.js}
RENAMED
|
File without changes
|