Nodemailer and Outlook 365 SMPT, 535 5.7.139 Authentication unsuccessful not meet criteria

Nikola Milović 1 Reputation point
2021-11-28T13:14:40.16+00:00

I am trying to send emails from my outlook account ( office 365 email ) to myself/ to others in my organization. And from my email to my users that may or may not be on office.

I am using Nodejs and Typescript and this is all happening on the server from my own email (our organizations email). So this should require no human interaction/ the access token or whatever shouldn't expire, need manual setting but rather this should be automatic or set once.

I tried the following setup

const mailOptions = {
        from: "FROM@DOMAIN.AI",
        to: "TO@DOMAIN.AI",
        subject: req.title,
        text: req.contents,
      };

      const info = await transporter.sendMail(mailOptions);



export const transporter = nodemailer.createTransport({
  service: "Outlook365",
  auth: {
    user: "FROM@DOMAIN.AI",
    pass: "pass",
  },
});

This is the error I am getting

[Node] error:   Invalid login: 535 5.7.139 Authentication unsuccessful, the request did not meet the criteria to be authenticated successfully. Contact your administrator. [VI1PR0501CA0022.eurprd05.prod.outlook.com]

This is happening on localhost while developing locally, but later I am gonna deploy this to heroku.

What I tried:

1) Tried this solution and enabled Authenticated SMPT
2) Tried using OAUTH and registering an azure project, but there are no resources on how to do SERVER-TO-SERVER communication instead of client to server.

What I need to happen:

1) I have personal email A in an organization and we have a shared inbox B. Ideally I'd be able to send email from B to B ( when user sends us a message it's send to the server and ideally we'd receive it in the shared inbox )

2) Be able to send from B (shared inbox ) to other users outside of our organization (the users of our apps). I mean I can send from personal email A but I'd like them to see the email B as from and to reply to email B

After hours of searching and reading the docs, I am unable to find whether or not this is possible. All solutions mention Azure and policies and such while I don't even use Azure in my app. I just need to send emails via our business email (shared inbox email) to ourself and to our users. I don't use any of the azure services, the docs are huge and are hard to navigate so I have no idea what is happening.

JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
883 questions
Outlook Management
Outlook Management
Outlook: A family of Microsoft email and calendar products.Management: The act or process of organizing, handling, directing or controlling something.
4,913 questions
Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,217 questions
{count} votes

1 answer

Sort by: Most helpful
  1. MAZEED 1 Reputation point
    2023-06-16T10:35:19.1966667+00:00

    I will be happy to know if anyone has gotten an update regarding "Nodemailer and Outlook 365 SMPT, 535 5.7.139 Authentication unsuccessful not meet criteria" - or if I get a referral to where i can get related support.