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

1 email node.js nodemailer

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

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
Run Code Online (Sandbox Code Playgroud)

和:

"email": {
    "email": "abcde@abc.cu",
    "password": ""
  }
Run Code Online (Sandbox Code Playgroud)

我卡在这,我曾尝试与"password": """password": " "并没有什么作品。电子邮件服务器是 Zimbra。这给了我以下错误:

*-------------------------*
The server IS NOT READY to take the messages: Error: Invalid login: 535 5.7.8 Error: authentication failed: authentication failure
*-------------------------*
Run Code Online (Sandbox Code Playgroud)

你好...

har*_*ant 5

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

fromto选择从邮件选项分别设置。

您可以尝试以下操作:

    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();
   });
Run Code Online (Sandbox Code Playgroud)