1

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 email A in 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 I want it to be received in the shared inbox)

  2. Be able to send from B (shared inbox ) to other users outside of our organization (our apps users)

After hours of searching and reading the docs, I am unable to find whether or not this is possible. All solutions mention Azure 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.

Nikola-Milovic
  • 1,393
  • 1
  • 12
  • 35

2 Answers2

0

You need to disable the Azure Security Defaults by toggling the Enable Security Defaults to No.

  • Sign in to the Azure portal as a Security administrator. Conditional Access administrator, or Global administrator,
  • Browse to Azure Active Directory Properties
  • Select Manage security defaults.
  • Set the Enable security defaults toggle to No.
  • Select Save.

You need to wait for some time (couple of minutes), and the problem will be solved.

Ghyath Serhal
  • 7,466
  • 6
  • 44
  • 60
0

Is Multi-factor authentication enabled.? Then you have to generate app password and use that

nadun
  • 21
  • 7