535 5.7.139 身份验证失败,用户被组织的安全默认策略锁定。请联系您的管理员

问题描述 投票:0回答:1

535 5.7.139 身份验证失败,用户被组织的安全默认策略锁定。请联系您的管理员。通过 Office365 smtp 主机和 587 作为端口发送邮件时发生此错误。从管理中心禁用了 MFA,并启用了 smtp 身份验证,并且我正在使用正确的帐户凭据。

import nodemailer from 'nodemailer';
import { MailInterface } from '../models/sendMail';

export default async function main(options: MailInterface) {
    try {
        const transporter = nodemailer.createTransport({
            host: process.env.SMTP_HOST,
            // host: "smtp.gmail.com",
            port: process.env.SMTP_PORT,
            secure: false,
            requireTLS: true,
            auth: {
                user: process.env.SMTP_USERNAME,
                pass: process.env.SMTP_PASSWORD,
            },
            logger: true,
            connectionTimeout: 10000, // 10 seconds
            greetingTimeout: 10000, // 10 seconds
            socketTimeout: 10000 // 10 seconds
        });

        console.log("SMTP connection established");

        // send mail with defined transport object
        const info = await transporter.sendMail({
            from: process.env.SMTP_USERNAME,
            to: options.to,
            subject: options.subject,
            html: options.html,
            
            headers: { 'x-myheader': 'test header' }
        });

        console.log("Message sent: %s", info.response);
    } catch (error) {
        console.error("Error sending email:", error);
        throw new Error("Failed to send email");
    }
}

我已经尝试过以下文档中提到的方法https://learn.microsoft.com/en-us/exchange/troubleshoot/email-delivery/fix-issues-with-printers-scanners-and-lob-applications-that -使用关闭发送电子邮件#错误身份验证不成功

node.js azure office365 nodemailer smtp-auth
1个回答
0
投票

现在问题解决了吗?我也遇到了相同的问题,该文档https://learn.microsoft.com/en-us/exchange/troubleshoot/email-delivery/fix-issues-with-printers-scanners-and -lob-applications-that-send-email-using-off#error-authentication-unsuccessful中,没有535 5.7.139 身份验证不成功,用户被组织的安全默认策略锁定。的解决方法

© www.soinside.com 2019 - 2024. All rights reserved.