refix email attachments array

This commit is contained in:
Dave Conway-Jones 2021-04-01 09:36:36 +01:00
parent 4697636055
commit 1c256fd3b3
No known key found for this signature in database
GPG Key ID: 88BA2B8A411BE9FF
2 changed files with 5 additions and 4 deletions

View File

@ -119,15 +119,16 @@ module.exports = function(RED) {
else {
var payload = RED.util.ensureString(msg.payload);
sendopts.text = payload; // plaintext body
if (/<[a-z][\s\S]*>/i.test(payload)) {
if (/<[a-z][\s\S]*>/i.test(payload)) {
sendopts.html = payload; // html body
if (msg.hasOwnProperty("plaintext")) {
var plaintext = RED.util.ensureString(msg.plaintext);
sendopts.text = plaintext; // plaintext body - specific plaintext version
}
}
if (msg.attachments && Array.isArray(msg.attachments)) {
sendopts.attachments = msg.attachments;
if (msg.attachments) {
if (!Array.isArray(msg.attachments)) { sendopts.attachments = [ msg.attachments ]; }
else { sendopts.attachments = msg.attachments; }
for (var a=0; a < sendopts.attachments.length; a++) {
if (sendopts.attachments[a].hasOwnProperty("content")) {
if (typeof sendopts.attachments[a].content !== "string" && !Buffer.isBuffer(sendopts.attachments[a].content)) {

View File

@ -1,6 +1,6 @@
{
"name": "node-red-node-email",
"version": "1.10.1",
"version": "1.11.0",
"description": "Node-RED nodes to send and receive simple emails.",
"dependencies": {
"imap": "^0.8.19",