ssl 无法使用Nodemailer连接到outlook.comSMTP

0qx6xfy6  于 2023-03-30  发布在  其他
关注(0)|答案(6)|浏览(204)

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

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

这是我收到的错误,当我试图发送邮件。
[错误:139668100495168:错误:1408 F10 B:SSL例程:SSL3_GET_RECORD:错误的版本号:../deps/openssl/openssl/ssl/s3_pkt.c:337:]
当我尝试将ignoreTLS设置为true时,这就是我得到的结果
{ [AuthError:登录无效- 530 5.7.0必须发出STARTTLS命令first] name:'AuthError',数据:'530 5.7.0必须先发出STARTTLS命令' }
我做错什么了吗?请帮帮我。

hec6srdp

hec6srdp1#

我遇到了同样的问题,直到我偶然发现了https://github.com/andris9/Nodemailer/issues/165
尝试添加tls密码选项以使用SSLv 3。

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: "user@outlook.com",
        pass: "password"
    },
    tls: {
        ciphers:'SSLv3'
    }
});

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

var transport = nodemailer.createTransport("SMTP", {
    service: "hotmail",
    auth: {
        user: "user@outlook.com",
        pass: "password"
    }
});
jqjz2hbq

jqjz2hbq2#

let testAccount = await nodemailer.createTestAccount();
let transporter = nodemailer.createTransport({
  service: "Outlook365",
  host: "smtp.office365.com",
  port: "587",
  tls: {
    ciphers: "SSLv3",
    rejectUnauthorized: false,
  },
  auth: {
    user: "**********",
    pass: "*******",
  },
});
let info = await transporter.sendMail({
  from: "********", // sender address
  to: to, // list of receivers
  subject: subject, // Subject line
  html: html, // html body
});

You can use thing configuration for nodemailer with outlook account
kh212irz

kh212irz3#

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

var transporter = nodemailer.createTransport('smtp://username%40outlook.com:password@smtp-mail.outlook.com');
bkhjykvo

bkhjykvo4#

基本上,错误来自SSLv3,所以我有我的解决方案

let transporter = nodemailer.createTransport({
    host: 'smtp-mail.outlook.com',                  // hostname
    service: 'outlook',                             // service name
    secureConnection: false,
    tls: {
        ciphers: 'SSLv3'                            // tls version
    },
    port: 587,                                      // port
    auth: {
        user: "<Your Email>",
        pass: "<Password>"
    }
});
xyhw6mcr

xyhw6mcr5#

如果您使用的是v5+

const transporter = nodemailer.createTransport({
  host: "smtp-mail.outlook.com", 
  secureConnection: false, 
  port: 587, 
  service: "outlook",
  auth: {
    user: process.env.EMAIL_ID,
    pass: process.env.EMAIL_PASSWORD,
  },
  tls: {
    ciphers: "SSLv3",
  },
});
7ajki6be

7ajki6be6#

tls:{ ciphers:'SSLv 3' } +1工作
而对于第一个agr(“SMTP”,是不支持以后的版本.一个将不得不降级nodemailer

相关问题