使用nodemailer通过zimbra smtp发送没有密码的电子邮件

即时通讯使用nodemailer发送电子邮件在web应用程序中使用keystonejs作为cms。 Web应用程序存储在服务器中,而电子邮件服务器存储在其他服务器中,但服务器之间的SMTP通信不需要密码。 现在,我需要发送电子邮件给其他人在需要使用通用帐户没有密码字段,因为是不是必须的。 这是我的nodemailerconfiguration:

var selfSignedConfig = { host: 'smtp.abc.cu', port: 25, secure: false, // use TLS auth: { user: email.email, pass: email.password //NOT REQUIRED }, tls: { // do not fail on invalid certs rejectUnauthorized: false } }; var transporter = nodemailer.createTransport(selfSignedConfig); // verify connection configuration 

和:

 "email": { "email": "abcde@abc.cu", "password": "" } 

请填写这个,我已经尝试了“密码”:“”和“密码”:“”,没有任何工作。 电子邮件服务器是Zimbra。 这给了我错误:

 *-------------------------* Server IS NOT READY to take the messages: Error: Invalid login: 535 5.7.8 Error: authentication failed: authentication failure *-------------------------* 

问候…

在我们的例子中,我们删除了tlsauthsecure字段,它在我们的SMTP服务器上工作。

选项从邮件选项单独设置。

您可以尝试以下方法:

  var nodemailer = require ('nodemailer'), _ = require ('lodash') var selfSignedConfig = { host: 'smtp.abc.cu', port: 25 }; var transporter = nodemailer.createTransport(selfSignedConfig); var attachFiles = attachments?attachments:[]; var attachObjArray = []; _.forEach( attachFiles, filePath=>attachObjArray.push({path:filePath}) ); var mailOptions = { from: fromEmail, // sender address (who sends) to: toEmail, // list of receivers (who receives) subject: subject, // Subject line html: body, // html body attachments:attachObjArray //attachment path with file name }; // send mail with defined transport object transporter.sendMail(mailOptions, function(error, info) { if(error){ return console.log(error); } else { console.log('Message sent: ' + info.response); } done(); });