1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00

Fix email msg cloning

to close #442
to close  #461
This commit is contained in:
Dave Conway-Jones 2018-08-30 13:05:39 +01:00
parent a94157efe6
commit 52df7cb30f
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
2 changed files with 6 additions and 6 deletions

View File

@ -190,7 +190,7 @@ module.exports = function(RED) {
// will be used to populate the email.
// DCJ NOTE: - heirachical multipart mime parsers seem to not exist - this one is barely functional.
function processNewMessage(msg, mailMessage) {
msg = JSON.parse(JSON.stringify(msg)); // Clone the message
msg = RED.util.cloneMessage(msg); // Clone the message
// Populate the msg fields from the content of the email message
// that we have just parsed.
msg.payload = mailMessage.text;
@ -198,9 +198,9 @@ module.exports = function(RED) {
msg.date = mailMessage.date;
msg.header = mailMessage.headers;
if (mailMessage.html) { msg.html = mailMessage.html; }
if (mailMessage.to && mailMessage.from.to > 0) { msg.to = mailMessage.to; }
if (mailMessage.cc && mailMessage.from.cc > 0) { msg.cc = mailMessage.cc; }
if (mailMessage.bcc && mailMessage.from.bcc > 0) { msg.bcc = mailMessage.bcc; }
if (mailMessage.to && mailMessage.to.length > 0) { msg.to = mailMessage.to; }
if (mailMessage.cc && mailMessage.cc.length > 0) { msg.cc = mailMessage.cc; }
if (mailMessage.bcc && mailMessage.bcc.length > 0) { msg.bcc = mailMessage.bcc; }
if (mailMessage.from && mailMessage.from.length > 0) { msg.from = mailMessage.from[0].address; }
if (mailMessage.attachments) { msg.attachments = mailMessage.attachments; }
else { msg.attachments = []; }

View File

@ -1,11 +1,11 @@
{
"name": "node-red-node-email",
"version": "1.0.0",
"version": "1.0.1",
"description": "Node-RED nodes to send and receive simple emails",
"dependencies": {
"imap": "^0.8.19",
"mailparser": "^0.6.2",
"nodemailer": "^4.6.4",
"nodemailer": "^4.6.8",
"poplib": "^0.1.7"
},
"repository": {