最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

无法使用outlook设置nodemailer

运维笔记admin9浏览0评论

无法使用outlook设置nodemailer

无法使用outlook设置nodemailer

我正在使用“nodemailer”:“^ 4.6.8”和“nodemailer-smtp-transport”:“^ 2.7.4”。我正在我的网站上开发联系表单,并尝试通过Outlook发送表单邮件。从互联网上的一些例子我尝试了这个代码,其中[email protected]是我的电子邮件地址:

  const transport = nodemailer.createTransport({
        service: "Hotmail",
        auth: {
            user: "[email protected]",
            pass: "xxxxxxxx"
        }
    });

    var mailOptions = {
        from: '[email protected]', // sender address
        to: '[email protected]', // my mail
        subject: `message subject`, // Subject line
        text: 'plain text', // plain text body
        // html: params.html, // html body
        // attachments: params.attachments
    };

    transport.sendMail(mailOptions, (error, info) => {
        if (error) {
            return console.log('Error while sending mail: ' + error);
        } else {
            console.log('Message sent: %s', info.messageId);
        }
        transport.close(); // shut down the connection pool, no more messages.
    });

但此代码在控制台错误中给出:

Error while sending mail: Error: Message failed: 554 5.2.0 STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message Cannot submit message. 16.55847:62090000, 17.43559:0000000094000000000000000100000000000000, 20.52176:140FCC84140010100A00FE67, 20.50032:140FCC84841710100B004536, 0.35180:6E060000, 255.23226:0A000055, 255.27962:0A000000, 255.27962:0E000000, 255.31418:80030400, 16.55847:AC000000, 17.43559:0000000068010000000000000200000000000000, 20.52176:140FCC8414001010D5050000, 20.50032:140FCC8484171010DA050000, 0.35180:0A001286, 255.23226:DF050000, 255.27962:0A000000, 255.27962:32000000, 255.17082:DC040000, 0.27745:E9050000, 4.21921:DC040000, 255.27962:FA000000, 255.1494:0A005384, 0.37692:01000100, 0.37948:00000600, 5.33852:00000000534D545000000100, 4.56248:DC040000, 7.40748:010000000000010B32303A48, 7.57132:000000000000000039313A36, 1.63016:32000000, 4.39640:DC040000, 8.45434:00000600ED8A4ABA000000000000000036000000, 5.10786:0000000031352E32302E313232382E3032303A4845315052303830314D42323039313A36646663323235632D353465312D346233312D383138612D3134643735373464633538620000000000, 255.1750:2F060000, 255.31418:40000730, 0.22753:34060000, 255.21817:DC040000, 4.60547:DC040000, 0.21966:0A001780, 4.30158:DC040000 [Hostname=HE1PR0801MB2091.eurprd08.prod.outlook]

不知道该做什么,提前谢谢!

回答如下:

事实证明,代码是正确的,这是安全问题。我只能从我的帐户发送信件,而不是任何其他人,所以使用邮件选项一切正常:

 let mailOptions = {
        from: '[email protected]', // sender address
        to: '[email protected]', // list of receivers
        subject: `subject`, // Subject line
        text: 'text', // plain text body
        // html: html, // html body
        // attachments: attachments
    };

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论