nodemailer 和 zoho 电子邮件发出“530 必须先发出 STARTTLS 命令”。

Rah*_*uly 4 zoho node.js nodemailer

我正在使用最新版本的 nodemailer 版本 4.1.0。我尝试使用此处提供的示例代码 https://nodemailer.com/smtp/

这是我的代码

 let transporter = nodemailer.createTransport({
        host: 'smtp.zoho.com',
        port:587,
        secure: false,           
        auth: {
            user: this.user,
            pass: this.password
        }
    });

     var mailOptions: nodemailer.SendMailOptions = {
        from: ****@***.com,
        to: test@abc.com,
        subject: 'Hello ?',
        text: 'Hello world ?', 
        html: '<b>Hello world ?</b>'
    };

   transporter
            .sendMail(mailOptions)
            .then(
                (info) => {
                  //  console.log(info);
                    resolve({status: info.messageId})
                }
            )
            .catch(err => {
             //   console.log(err);
                reject({status: err.toString()})
            })
Run Code Online (Sandbox Code Playgroud)

我收到以下错误。我已将安全标志设置为 false,并且还使用了 ignodeTLS。nodemailer 0.7.1 之前的版本没有任何问题。我是否错过了任何特定配置?

   { Error: Invalid login: 530 Must issue a STARTTLS command first.
at SMTPConnection._formatError 
(C:\Project\NotificationService\node_modules\nodemailer\lib\smtp-connection\index.js:577:19)
at SMTPConnection._actionAUTHComplete (C:\Project\NotificationService\node_modules\nodemailer\lib\smtp-connection\index.js:1306:34)
at SMTPConnection._responseActions.push.str (C:\Project\NotificationService\node_modules\nodemailer\lib\smtp-connection\index.js:349:26)
at SMTPConnection._processResponse (C:\Project\NotificationService\node_modules\nodemailer\lib\smtp-connection\index.js:733:20)
at SMTPConnection._onData (C:\Project\NotificationService\node_modules\nodemailer\lib\smtp-connection\index.js:529:14)
at Socket._socket.on.chunk (C:\Project\NotificationService\node_modules\nodemailer\lib\smtp-connection\index.js:481:47)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at TCP.onread (net.js:548:20)
  code: 'EAUTH',
  response: '530 Must issue a STARTTLS command first.',
  responseCode: 530,
  command: 'AUTH PLAIN' }
Run Code Online (Sandbox Code Playgroud)

Ric*_*rma 6

您也可以在没有这些 tls 参数的情况下使用它,默认值为 false。您收到错误是因为您没有在 nodemailer 中传递 service:'zoho'

let transporter = nodemailer.createTransport({
        service:'Zoho',
        host: this.service,
        port:587,
        secure: false,
        auth: {
            user: this.user,
            pass: this.password
        }
    });
Run Code Online (Sandbox Code Playgroud)