node.js - Nodemailer 和 Outlook 365、535 5.7.139 身份验证失败不符合条件

标签 node.js azure email outlook nodemailer

我正在尝试从我的 Outlook 帐户(Office 365 电子邮件)向我自己/组织中的其他人发送电子邮件。以及从我的电子邮件发送给可能在办公室或不在办公室的用户。

我正在使用 Nodejs 和 Typescript,这一切都是通过我自己的电子邮件(我们组织的电子邮件)在服务器上发生的。因此,这应该不需要人工交互/访问 token 或任何不应过期的内容,需要手动设置,而应该是自动的或设置一次。

我尝试了以下设置

   const mailOptions = {
        from: "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f7b1a5b8bab7b3b8bab6beb9d9b6be" rel="noreferrer noopener nofollow">[email protected]</a>",
        to: "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d5819a95919a98949c9bfb949c" rel="noreferrer noopener nofollow">[email protected]</a>",
        subject: req.title,
        text: req.contents,
      };

      const info = await transporter.sendMail(mailOptions);
export const transporter = nodemailer.createTransport({
  service: "Outlook365",
  auth: {
    user: "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7f392d30323f3b30323e3631513e36" rel="noreferrer noopener nofollow">[email protected]</a>",
    pass: "pass",
  },
});

这是我遇到的错误

[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]

这是在本地开发时在本地主机上发生的,但稍后我会将其部署到heroku。

我尝试过的:

  1. Tried this solution and enabled Authenticated SMPT
  2. 尝试使用 OAUTH 并注册 Azure 项目,但没有有关如何进行服务器到服务器通信(而不是客户端到服务器)的资源。

我需要发生什么:

  1. 我在组织中有电子邮件 A,并且我们有一个共享收件箱 B。理想情况下,我能够从 B 向 B 发送电子邮件(当用户向我们发送消息时,我希望它在共享收件箱中收到) )

  2. 能够从 B(共享收件箱)发送给我们组织外部的其他用户(我们的应用用户)

经过几个小时的搜索和阅读文档,我无法确定这是否可行。所有解决方案都提到 Azure,而我什至不在我的应用程序中使用 Azure。我只需要通过我们的商务电子邮件(共享收件箱电子邮件)向我们自己和我们的用户发送电子邮件。我不使用任何 Azure 服务,文档很大并且很难导航,所以我不知道发生了什么。

最佳答案

您需要通过将“启用安全默认值”切换为“否”来禁用 Azure 安全默认值。

  • 以安全管理员身份登录 Azure 门户。条件访问管理员或全局管理员,
  • 浏览到 Azure Active Directory 属性
  • 选择管理安全默认设置。
  • 将“启用安全默认值”开关设置为“否”。
  • 选择“保存”。

您需要等待一段时间(几分钟),问题就会解决。

关于node.js - Nodemailer 和 Outlook 365、535 5.7.139 身份验证失败不符合条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70143722/

相关文章:

javascript - 通过 Node 将记录插入 MySQL 数据库时出错

javascript - puppeteer querySelector 不是有效的选择器

javascript - 在 mysql Sequelize + Nodejs 中将数组和对象转换为批量插入

azure - 有没有办法限制同一 Azure 订阅中其他 'Owners' 的资源访问?

azure - 未经授权,输入的授权 token 无法满足请求

java - 更改配置以触发电子邮件发送自动化测试结果

node.js - Node.js 中的环境 TypeScript 模块

java - 单击按钮无响应

PHP fatal error : require_once(): Failed opening required 'Mail.php' (include_path ='.:/usr/share/pear:/usr/share/php' )

azure - 是否可以安排新数据层 SQL Azure 实例的规模?