mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Add done/complete to email node
and fix .from field
This commit is contained in:
parent
e8a7af18d6
commit
1f0ab0937d
@ -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
|
||||
|
@ -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",
|
||||
|
Loading…
x
Reference in New Issue
Block a user