【问题标题】:Send email without password using nodemailer over a zimbra smtp通过 zimbra smtp 使用 nodemailer 发送没有密码的电子邮件
【发布时间】:2018-05-15 16:40:32
【问题描述】:

我使用 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

和:

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

我坚持这一点,我尝试了"password": """password": " ",但没有任何效果。电子邮件服务器是 Zimbra。 这给了我以下错误:

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

您好……

【问题讨论】:

  • 根据错误消息,即使rejectUnauthorized 设置为false,也需要密码
  • 是的,但问题是电子邮件帐户没有密码,就是这样。

标签: node.js email nodemailer


【解决方案1】:

在我们的例子中,我们删除了 tlsauthsecure 字段,它在我们的 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();
   });

【讨论】:

  • 嗨 Juan - 如果这对你有帮助,请接受这个作为答案
猜你喜欢
  • 2017-05-16
  • 2021-12-28
  • 2018-08-06
  • 1970-01-01
  • 2022-10-14
  • 2021-08-14
  • 2017-08-08
  • 2018-09-01
  • 1970-01-01
相关资源
最近更新 更多