Add done/complete to email node

and fix .from field
This commit is contained in:
Dave Conway-Jones 2019-09-24 21:44:56 +01:00
parent e8a7af18d6
commit 1f0ab0937d
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
2 changed files with 5 additions and 4 deletions

View File

@ -75,8 +75,9 @@ module.exports = function(RED) {
}
var smtpTransport = nodemailer.createTransport(smtpOptions);
this.on("input", function(msg) {
this.on("input", function(msg, send, done) {
if (msg.hasOwnProperty("payload")) {
send = send || node.send;
if (smtpTransport) {
node.status({fill:"blue",shape:"dot",text:"email.status.sending"});
if (msg.to && node.name && (msg.to !== node.name)) {
@ -123,6 +124,7 @@ module.exports = function(RED) {
} else {
node.log(RED._("email.status.messagesent",{response:info.response}));
node.status({text:"",response:info.response,msg:{to:msg.to,topic:msg.topic,id:msg._msgid}});
if (done) { done(); }
}
});
}
@ -208,12 +210,11 @@ module.exports = function(RED) {
msg.date = mailMessage.date;
msg.header = {};
mailMessage.headers.forEach((v, k) => {msg.header[k] = v;});
if (mailMessage.html) { msg.html = mailMessage.html; }
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.from && mailMessage.from.value && mailMessage.from.value.length > 0) { msg.from = mailMessage.from.value[0].address; }
if (mailMessage.attachments) { msg.attachments = mailMessage.attachments; }
else { msg.attachments = []; }
node.send(msg); // Propagate the message down the flow

View File

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