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

fix merge email.js

This commit is contained in:
Dave C-J 2014-09-03 19:34:52 +01:00
parent 7da7887ed2
commit fa8d31609e

View File

@ -73,11 +73,10 @@ module.exports = function(RED) {
if (msg != null) { if (msg != null) {
if (smtpTransport) { if (smtpTransport) {
node.status({fill:"blue",shape:"dot",text:"sending"}); node.status({fill:"blue",shape:"dot",text:"sending"});
var payload = RED.util.ensureString(msg.payload); var payload = RED.util.ensureString(msg.payload);
smtpTransport.sendMail({ smtpTransport.sendMail({
from: node.userid, // sender address from: node.userid, // sender address
to: node.name, // comma separated list of receivers to: msg.to || node.name, // comma separated list of addressees
subject: msg.topic, // subject line subject: msg.topic, // subject line
text: payload // plaintext body text: payload // plaintext body
}, function(error, info) { }, function(error, info) {
@ -99,7 +98,7 @@ module.exports = function(RED) {
userid: {type:"text"}, userid: {type:"text"},
password: {type: "password"}, password: {type: "password"},
global: { type:"boolean"} global: { type:"boolean"}
} }
}); });
function EmailInNode(n) { function EmailInNode(n) {
@ -109,7 +108,7 @@ module.exports = function(RED) {
this.inserver = n.server || emailkey.server || "imap.gmail.com"; this.inserver = n.server || emailkey.server || "imap.gmail.com";
this.inport = n.port || emailkey.port || "993"; this.inport = n.port || emailkey.port || "993";
var flag = false; var flag = false;
if (this.credentials && this.credentials.hasOwnProperty("userid")) { if (this.credentials && this.credentials.hasOwnProperty("userid")) {
this.userid = this.credentials.userid; this.userid = this.credentials.userid;
} else { } else {
@ -178,7 +177,7 @@ module.exports = function(RED) {
pay.date = Imap.parseHeader(buffer).date[0]; pay.date = Imap.parseHeader(buffer).date[0];
} else { } else {
var parts = buffer.split("Content-Type"); var parts = buffer.split("Content-Type");
for (var p in parts) { for (var p = 0; p < parts.length; p++) {
if (parts[p].indexOf("text/plain") >= 0) { if (parts[p].indexOf("text/plain") >= 0) {
pay.payload = parts[p].split("\n").slice(1,-2).join("\n").trim(); pay.payload = parts[p].split("\n").slice(1,-2).join("\n").trim();
} }
@ -245,6 +244,6 @@ module.exports = function(RED) {
userid: {type:"text"}, userid: {type:"text"},
password: {type: "password"}, password: {type: "password"},
global: { type:"boolean"} global: { type:"boolean"}
} }
}); });
} }