From bbf2330b1a8e6bb24c9d2ca320ee6c56aa5a0d3a Mon Sep 17 00:00:00 2001
From: wooferguy 
Date: Sat, 11 Feb 2023 14:50:48 +1300
Subject: [PATCH] Cleanup and README
Remove old code, update readme
---
 social/email/61-email.js | 49 ----------------------------------------
 social/email/README.md   | 12 ++++++++++
 2 files changed, 12 insertions(+), 49 deletions(-)
diff --git a/social/email/61-email.js b/social/email/61-email.js
index b01da58d..84b4e583 100644
--- a/social/email/61-email.js
+++ b/social/email/61-email.js
@@ -578,55 +578,6 @@ module.exports = function(RED) {
             }
         }  // End of checkEmail
 
-/*        if (node.protocol === "IMAP") {
-            var tout = (node.repeat > 0) ? node.repeat - 500 : 15000;
-            if(node.authentication == "OAUTH") {
-                imap = new Imap({
-                    user: node.userid,
-                    oauth: node.token,
-                    host: node.inserver,
-                    port: node.inport,
-                    tls: node.useSSL,
-                    autotls: node.autotls,
-                    tlsOptions: { rejectUnauthorized: false },
-                    connTimeout: tout,
-                    authTimeout: tout
-                });
-            } else if(node.authentication == "XOAUTH2") {
-                imap = new Imap({
-                    user: node.userid,
-                    xoauth2: node.token,
-                    host: node.inserver,
-                    port: node.inport,
-                    tls: node.useSSL,
-                    autotls: node.autotls,
-                    tlsOptions: { rejectUnauthorized: false },
-                    connTimeout: tout,
-                    authTimeout: tout
-                });
-            } else {
-                imap = new Imap({
-                    user: node.userid,
-                    password: node.password,
-                    host: node.inserver,
-                    port: node.inport,
-                    tls: node.useSSL,
-                    autotls: node.autotls,
-                    tlsOptions: { rejectUnauthorized: false },
-                    connTimeout: tout,
-                    authTimeout: tout
-                });
-            }
-            imap.on('error', function(err) {
-                if (err.errno !== "ECONNRESET") {
-                    s = false;
-                    node.error(err.message,err);
-                    node.status({fill:"red",shape:"ring",text:"email.status.connecterror"});
-                }
-                setInputRepeatTimeout();
-            });
-        }*/
-
         node.on("input", function(msg, send, done) {
             send = send || function() { node.send.apply(node,arguments) };
             checkEmail(msg,send,done);
diff --git a/social/email/README.md b/social/email/README.md
index 58192c4c..b59163a3 100644
--- a/social/email/README.md
+++ b/social/email/README.md
@@ -9,6 +9,8 @@ Pre-requisite
 You will need valid email credentials for your email server. For GMail this may mean
 getting an application password if you have two-factor authentication enabled.
 
+For Exchange and Outlook 365 you must use OAuth2.0.
+
 **Note :** Version 1.x of this node requires **Node.js v8** or newer.
 
 Install
@@ -26,6 +28,13 @@ GMail users
 If you are accessing GMail you may need to either enable an application password,
 or enable less secure access via your Google account settings.
 
+Office 365 users
+-----------
+
+If you are accessing Exchnage you will need to register an application through their platform and use OAuth2.0.
+Details on how to do this can be found here.
+
+
 Usage
 -----
 
@@ -42,6 +51,9 @@ If there is text/html then that is returned in `msg.html`. `msg.from` and
 Additionally `msg.header` contains the complete header object including
 **to**, **cc** and other potentially useful properties.
 
+Modern authentication through OAuth2.0 is supported, but must be triggered by an incoming access token and
+can only be automatically triggered upstream.
+
 ### Output node
 
 Sends the `msg.payload` as an email, with a subject of `msg.topic`.