mirror of
https://github.com/node-red/node-red-nodes.git
synced 2025-03-01 10:37:43 +00:00
Update email node to point to nodejs18 and latest libs
delay creation of oauth connection
This commit is contained in:
parent
ea48b6acdd
commit
df75872826
@ -72,31 +72,45 @@ module.exports = function(RED) {
|
||||
tls: {rejectUnauthorized: node.tls}
|
||||
}
|
||||
|
||||
if (node.authtype === "BASIC" ) {
|
||||
smtpOptions.auth = {
|
||||
user: node.userid,
|
||||
pass: node.password
|
||||
};
|
||||
var smtpTransport;
|
||||
if (node.authtype === "XOAUTH2") {
|
||||
node.log("Using OAuth - setup transport later.")
|
||||
}
|
||||
else if (node.authtype === "XOAUTH2") {
|
||||
var value = RED.util.getMessageProperty(msg,node.token);
|
||||
if (value !== undefined) {
|
||||
if (node.saslformat) {
|
||||
//Make base64 string for access - compatible with outlook365 and gmail
|
||||
saslxoauth2 = Buffer.from("user="+node.userid+"\x01auth=Bearer "+value+"\x01\x01").toString('base64');
|
||||
} else {
|
||||
saslxoauth2 = value;
|
||||
}
|
||||
else {
|
||||
if (node.authtype === "BASIC" ) {
|
||||
smtpOptions.auth = {
|
||||
user: node.userid,
|
||||
pass: node.password
|
||||
};
|
||||
}
|
||||
smtpOptions.auth = {
|
||||
type: "OAuth2",
|
||||
user: node.userid,
|
||||
accessToken: saslxoauth2
|
||||
};
|
||||
smtpTransport = nodemailer.createTransport(smtpOptions);
|
||||
}
|
||||
var smtpTransport = nodemailer.createTransport(smtpOptions);
|
||||
|
||||
this.on("input", function(msg, send, done) {
|
||||
|
||||
if (node.authtype === "XOAUTH2") {
|
||||
if (node.token) {
|
||||
var value = RED.util.getMessageProperty(msg,node.token);
|
||||
if (value !== undefined) {
|
||||
if (node.saslformat) {
|
||||
//Make base64 string for access - compatible with outlook365 and gmail
|
||||
saslxoauth2 = Buffer.from("user="+node.userid+"\x01auth=Bearer "+value+"\x01\x01").toString('base64');
|
||||
} else {
|
||||
saslxoauth2 = value;
|
||||
}
|
||||
}
|
||||
smtpOptions.auth = {
|
||||
type: "OAuth2",
|
||||
user: node.userid,
|
||||
accessToken: saslxoauth2
|
||||
};
|
||||
smtpTransport = nodemailer.createTransport(smtpOptions);
|
||||
}
|
||||
else {
|
||||
node.warn(RED._("email.errors.notoken"));
|
||||
}
|
||||
}
|
||||
|
||||
if (msg.hasOwnProperty("payload")) {
|
||||
send = send || function() { node.send.apply(node,arguments) };
|
||||
if (smtpTransport) {
|
||||
|
@ -12,7 +12,8 @@ getting an application password if you have two-factor authentication enabled.
|
||||
For Exchange and Outlook 365 you must use OAuth2.0.
|
||||
|
||||
**Notes **:
|
||||
Version 2.x of this node requires **Node.js v14** or newer.
|
||||
Version 3.x of this node requires **Node.js v18** or newer.
|
||||
Version 2.x of this node requires **Node.js v16** or newer.
|
||||
Version 1.91 of this node required **Node.js v14** or newer.
|
||||
Previous versions of this node required **Node.js v8** or newer.
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "node-red-node-email",
|
||||
"version": "2.2.1",
|
||||
"version": "3.0.0",
|
||||
"description": "Node-RED nodes to send and receive simple emails.",
|
||||
"dependencies": {
|
||||
"imap": "^0.8.19",
|
||||
"node-pop3": "^0.9.0",
|
||||
"mailparser": "^3.6.9",
|
||||
"nodemailer": "^6.9.12",
|
||||
"smtp-server": "^3.13.3"
|
||||
"mailparser": "^3.7.1",
|
||||
"nodemailer": "^6.9.13",
|
||||
"smtp-server": "^3.13.4"
|
||||
},
|
||||
"bundledDependencies": [
|
||||
"imap",
|
||||
@ -33,7 +33,7 @@
|
||||
"mta"
|
||||
],
|
||||
"node-red": {
|
||||
"version": ">=1.0.0",
|
||||
"version": ">=2.0.0",
|
||||
"nodes": {
|
||||
"email": "61-email.js"
|
||||
}
|
||||
@ -44,6 +44,6 @@
|
||||
"url": "http://nodered.org"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
"node": ">=18.0.0"
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user