Add to, cc and bcc fields to incoming msg

To close #258 and to fix #260
This commit is contained in:
Dave Conway-Jones 2016-12-12 21:10:36 +00:00
parent d4e0e9b302
commit 0d0df5cef9
3 changed files with 17 additions and 19 deletions

View File

@ -147,7 +147,7 @@
<label for="node-input-disposition"><i class="fa fa-trash"></i> <span data-i18n="email.label.disposition"></span></label> <label for="node-input-disposition"><i class="fa fa-trash"></i> <span data-i18n="email.label.disposition"></span></label>
<select type="text" id="node-input-disposition"> <select type="text" id="node-input-disposition">
<option value="None" selected="selected">None</option> <option value="None" selected="selected">None</option>
<option value="Read">Mark Read/Answered</option> <option value="Read">Mark Read</option>
<option value="Delete">Delete</option> <option value="Delete">Delete</option>
</select> </select>
</div> </div>

View File

@ -183,17 +183,13 @@ module.exports = function(RED) {
msg.payload = mailMessage.text; msg.payload = mailMessage.text;
msg.topic = mailMessage.subject; msg.topic = mailMessage.subject;
msg.date = mailMessage.date; msg.date = mailMessage.date;
if (mailMessage.html) { if (mailMessage.html) { msg.html = 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.from && mailMessage.from.length > 0) { if (mailMessage.bcc && mailMessage.from.bcc > 0) { msg.bcc = mailMessage.bcc; }
msg.from = mailMessage.from[0].address; if (mailMessage.from && mailMessage.from.length > 0) { msg.from = mailMessage.from[0].address; }
} if (mailMessage.attachments) { msg.attachments = mailMessage.attachments; }
if (mailMessage.attachments) { else { msg.attachments = []; }
msg.attachments = mailMessage.attachments;
} else {
msg.attachments = [];
}
node.send(msg); // Propagate the message down the flow node.send(msg); // Propagate the message down the flow
} // End of processNewMessage } // End of processNewMessage
@ -322,11 +318,13 @@ module.exports = function(RED) {
return; return;
} }
var marks = false;
if (this.disposition === "Read") { marks = true; }
// We have the search results that contain the list of unseen messages and can now fetch those messages. // We have the search results that contain the list of unseen messages and can now fetch those messages.
var fetch = imap.fetch(results, { var fetch = imap.fetch(results, {
bodies: '', bodies: '',
struct: true, struct: true,
markSeen : true markSeen: marks
}); });
// For each fetched message returned ... // For each fetched message returned ...
@ -357,10 +355,10 @@ module.exports = function(RED) {
node.status({}); node.status({});
imap.end(); imap.end();
}; };
if (this.disposition == "Delete") { if (this.disposition === "Delete") {
imap.addFlags(results, "\Deleted", cleanup); imap.addFlags(results, "\Deleted", cleanup);
} else if (this.disposition == "Read") { } else if (this.disposition === "Read") {
imap.addFlags(results, "\Answered", cleanup); imap.addFlags(results, "\Seen", cleanup);
} else { } else {
cleanup(); cleanup();
} }

View File

@ -1,12 +1,12 @@
{ {
"name": "node-red-node-email", "name": "node-red-node-email",
"version": "0.1.12", "version": "0.1.13",
"description": "Node-RED nodes to send and receive simple emails", "description": "Node-RED nodes to send and receive simple emails",
"dependencies": { "dependencies": {
"nodemailer": "^1.11.0", "nodemailer": "^1.11.0",
"poplib": "^0.1.7", "poplib": "^0.1.7",
"mailparser": "^0.6.0", "mailparser": "^0.6.1",
"imap": "^0.8.17" "imap": "^0.8.19"
}, },
"repository": { "repository": {
"type": "git", "type": "git",