gpt4 book ai didi

node.js - 使用 Nodemailer 通过 zimbra smtp 发送无需密码的电子邮件

转载 作者:太空宇宙 更新时间:2023-11-03 23:01:19 25 4
gpt4 key购买 nike

我使用nodemailer在使用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
*-------------------------*

问候...

最佳答案

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

关于node.js - 使用 Nodemailer 通过 zimbra smtp 发送无需密码的电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47595691/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com