2017-09-12 51 views
1

我正在使用最新版本的nodemailer 4.1.0版。我尝试使用可在这里 https://nodemailer.com/smtp/nodemailer和zoho电子邮件问题'530必须首先发出STARTTLS命令。'

示例代码这里是我的代码

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: [email protected], 
     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()}) 
      }) 

我碰到下面的错误。我已将安全标志设置为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' } 
+0

https://www.zoho.eu/mail/help/zoho-smtp.html 他们不似乎允许不安全的SMTP。 –

+0

谢谢@BrahmaDev我正在浏览打印文件并添加服务:'Zoho',以及需要TLS:错误,并且我将其正常工作。 –

回答

0

你也可以使用这个没有这些tls参数的默认值是false。 你得到的错误,因为你不通过服务:在nodemailer“ZOHO”

let transporter = nodemailer.createTransport({ 
     service:'Zoho', 
     host: this.service, 
     port:587, 
     secure: false, 
     auth: { 
      user: this.user, 
      pass: this.password 
     } 
    }); 
+0

谢谢@Ricky sharma –

+0

欢迎@RahulGanguly –

0

通过分型准备(“@类型/ nodemailer”)文件后添加以下标志

1)服务: '百会'

2)的RequireTLS:假

它现在正在工作:)

let transporter = nodemailer.createTransport({ 
     service:'Zoho', 
     host: this.service, 
     port:587, 
     secure: false, 
     ignoreTLS:true, 
     requireTLS:false, 
     auth: { 
      user: this.user, 
      pass: this.password 
     } 
    }); 
相关问题