title: Modern Oauth2 authentication for sending mails using Nodemailer nodejs
body: <p>I am using <code>nodemailer</code> to send email in my nodejs application.</p>
  
  <pre><code>var payload = { auth: 
                 {
                  user: smtpuser,
                  pass: smtppass
                 },
                  to : toAddr,
                  from  : emailfrom,
                  cc : ccAddr,
                  subject : subject,
                  html    : content,
                  attachments: attachments
                };
  
  var transporter = nodemailer.createTransport(
                     { host: payload.host || 'smtp.office365.com', // Office 365 server
                       port: payload.port || 587,     // secure SMTP
                       secure:payload.secure || false, // false for TLS - as a boolean not string - but the default is false so just remove this completely
                       auth: payload.auth,
                       debug: true,
                       tls: payload.tls || {ciphers: 'SSLv3'}
                     });
  
  transporter.sendMail(payload, function (error, info) {
                  if (error) {
                      return console.log(error);
                  }
                  updateMessage(updatedMsg);
              });
  </code></pre>
  
  <p>I started getting this error: </p>
  
  <blockquote>
    <p>Error: Invalid log in: 535 5.7.3 Authentication unsuccessful [SN4PR0601CA0002.namprd06.prod.outlook.com]</p>
  </blockquote>
  
  <p>It seems my team has now disabled basic authentication. </p>
  
  <p>I need to implement modern authentication(Oauth2) to be able to send mails via <code>nodemailer</code> using the outlook id.</p>
  
  <p>Does anyone have any idea about this?
  What configuration(code) changes will that require ?</p>