node.js 无法使用 Nodemailer 连接到 Outlook.com SMTP

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19509357/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 16:03:14  来源:igfitidea点击:

Not able to connect to outlook.com SMTP using Nodemailer

node.jsssloutlooksmtpnodemailer

提问by Jeevan

I am creating the transport object like this.

我正在创建这样的传输对象。

var transport = nodemailer.createTransport("SMTP", {
        host: "smtp-mail.outlook.com", // hostname
        secureConnection: false, // use SSL
        port: 587, // port for secure SMTP
        auth: {
            user: "[email protected]",
            pass: "password"
        }
    });

This is the error which I am getting, when I try to send the mail.

这是我尝试发送邮件时遇到的错误。

[Error: 139668100495168:error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number:../deps/openssl/openssl/ssl/s3_pkt.c:337: ]

[错误:139668100495168:错误:1408F10B:SSL 例程:SSL3_GET_RECORD:错误的版本号:../deps/openssl/openssl/ssl/s3_pkt.c:337:]

When I tried setting ignoreTLS as true. This is what I am getting

当我尝试将 ignoreTLS 设置为 true 时。这就是我得到的

{ [AuthError: Invalid login - 530 5.7.0 Must issue a STARTTLS command first] name: 'AuthError', data: '530 5.7.0 Must issue a STARTTLS command first' }

{ [AuthError: Invalid login - 530 5.7.0 Must issue a STARTTLS command first] name: 'AuthError', data: '530 5.7.0 Must issue a STARTTLS command first' }

Am I doing something wrong? Please help.

难道我做错了什么?请帮忙。

回答by Ray L

I was having the same issue until I stumbled upon https://github.com/andris9/Nodemailer/issues/165

我遇到了同样的问题,直到我偶然发现https://github.com/andris9/Nodemailer/issues/165

Try adding the tls cipher option to use SSLv3.

尝试添加 tls 密码选项以使用 SSLv3。

var transport = nodemailer.createTransport("SMTP", {
    host: "smtp-mail.outlook.com", // hostname
    secureConnection: false, // TLS requires secureConnection to be false
    port: 587, // port for secure SMTP
    auth: {
        user: "[email protected]",
        pass: "password"
    },
    tls: {
        ciphers:'SSLv3'
    }
});

Alternatively, for hotmail/live/outlook you can simply use

或者,对于 hotmail/live/outlook,您可以简单地使用

var transport = nodemailer.createTransport("SMTP", {
    service: "hotmail",
    auth: {
        user: "[email protected]",
        pass: "password"
    }
});

回答by Richie_b

If you are using Nodemailer 1.x or greater you can use:

如果您使用的是 Nodemailer 1.x 或更高版本,您可以使用:

var transporter = nodemailer.createTransport('smtp://username%40outlook.com:[email protected]');

回答by user2412105

tls: { ciphers:'SSLv3' } +1 working

tls: { ciphers:'SSLv3' } +1 工作

and for first agr ("SMTP", is not support later version . one will have to downgrade nodemailler

对于第一个 agr(“SMTP”,不支持更高版本。必须降级 nodemailler