使用node365通过Office365 smtp发送电子邮件时出错(MEANjs脚手架)

问题描述 投票:9回答:3

我正在尝试使用Office365 SMTP使用Nodemailer发送电子邮件(在MEANjs脚手架中),但是我收到以下错误:

[Error: 140735277183760:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:../deps/openssl/openssl/ssl/s23_clnt.c:795:]

我正在使用以下Nodemailer选项:

{ 
    host: 'smtp.office365.com',
    port: '587',
    auth: { user: 'xxxx', pass: 'xxxx' },
    secure: 'false',
    tls: { ciphers: 'SSLv3' }
}

删除tls字段没有任何区别。我错过了什么?

node.js email office365 meanjs nodemailer
3个回答
20
投票

解决方案很简单。 'secure'字段应为'secureConnection'。生成配置的MEANjs脚手架使用“安全”字段创建了邮件选项。其余选项都很好。对于需要工作Office365 SMTP节点邮件选项块的任何人,以下内容应该有效:

{ 
    host: 'smtp.office365.com',
    port: '587',
    auth: { user: 'xxxx', pass: 'xxxx' },
    secureConnection: false,
    tls: { ciphers: 'SSLv3' }
}

4
投票

这个nodemailer文档https://nodemailer.com/2-0-0-beta/setup-smtp/确实声明了options.secure而不是options.secureConnection。在一个例子中,它还建议options.secure期望布尔值为true或false,而不是字符串值'true''false'。从''周围移除'false'对我有用。


0
投票

我知道这是旧的,但如果有人在2019年看到这个,你可以添加service: "Outlook365"

而且您不必指定连接选项。

Node Mailer Docs

let transporter = nodemailer.createTransport({
    service: "Outlook365",
    auth: {
      user: '[email protected]',
      pass: 'FROMUSERPASS'
    },    
  })

  let info = transporter.sendMail({
    from: '[email protected]',
    to: '[email protected]',
    subject: 'Test',
    text: 'hello world',
    html: '<h1>TEST</h1>'
  })
© www.soinside.com 2019 - 2024. All rights reserved.