@5minds/node-red-contrib-processcube-tools 1.0.1-feature-4d41c0-mff7tr8d → 1.0.1-feature-434c91-mffah0hd
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-sender/email-sender.js +24 -1
- package/package.json +1 -1
|
@@ -28,6 +28,29 @@ module.exports = function(RED) {
|
|
|
28
28
|
const secure = RED.util.evaluateNodeProperty(config.secure, config.secureType, node, msg);
|
|
29
29
|
const rejectUnauthorized = RED.util.evaluateNodeProperty(config.rejectUnauthorized, config.rejectUnauthorizedType, node, msg);
|
|
30
30
|
|
|
31
|
+
// Handle attachments and format them for Nodemailer
|
|
32
|
+
let processedAttachments = [];
|
|
33
|
+
if (attachments) {
|
|
34
|
+
// Check if it's a single attachment or an array
|
|
35
|
+
const attachmentArray = Array.isArray(attachments) ? attachments : [attachments];
|
|
36
|
+
|
|
37
|
+
for (const attachment of attachmentArray) {
|
|
38
|
+
try {
|
|
39
|
+
// Assuming the attachment object has a 'filename' and 'content' property
|
|
40
|
+
if (attachment.filename && attachment.content) {
|
|
41
|
+
processedAttachments.push({
|
|
42
|
+
filename: attachment.filename,
|
|
43
|
+
content: attachment.content
|
|
44
|
+
});
|
|
45
|
+
} else {
|
|
46
|
+
node.warn("Attachment object is missing 'filename' or 'content' property and will be ignored.");
|
|
47
|
+
}
|
|
48
|
+
} catch (e) {
|
|
49
|
+
node.error("Failed to process attachment: " + e.message);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
31
54
|
// Create SMTP transporter
|
|
32
55
|
const transporter = nodemailer.createTransport({
|
|
33
56
|
host: host,
|
|
@@ -53,7 +76,7 @@ module.exports = function(RED) {
|
|
|
53
76
|
bcc: bcc,
|
|
54
77
|
subject: subject,
|
|
55
78
|
html: Buffer.from(htmlContent, 'utf-8'),
|
|
56
|
-
attachments:
|
|
79
|
+
attachments: processedAttachments
|
|
57
80
|
};
|
|
58
81
|
|
|
59
82
|
// Send email
|
package/package.json
CHANGED