我在用nodemailer发送在线邮件时遇到了问题。虽然它可以在相同环境下与chilkat的mailman模块(node.js)一起正常工作
nodemailer版本
let transporter = nodemailer.createTransport({
host: "smtpauth.online.net",
port: 587,
secure: false,
auth: {
user: "xxx@domain.fr",
pass: "xxx",
},
tls: {
rejectUnauthorized: false,
},
});
transporter
.sendMail({
from: "xxx@domain.fr",
to: "true@eadress.fr",
subject: "Test online",
text: "Test online"
})
.then((info) => {
console.log("Preview URL: " + nodemailer.getTestMessageUrl(info));
})
.catch((error) => {
console.log(error);
});
chilkat-version
var mailman = new chilkat.MailMan();
mailman.SmtpHost = "smtpauth.online.net";
mailman.SmtpUsername = "xxx@domain.fr";
mailman.SmtpPassword = "xxx";
mailman.SmtpSsl = false;
mailman.StartTLS = true;
mailman.SmtpPort = 587;
var email = new chilkat.Email();
email.Subject = "Test online";
email.Body = "Test online";
email.From = "xxx@domain.fr";
var success = email.AddTo("Bob","true@eadress.fr");
success = mailman.SendEmail(email);
if (success !== true) {
console.log(mailman.LastErrorText);
return;
}
success = mailman.CloseSmtpConnection();
if (success !== true) {
console.log("Connection to SMTP server not closed cleanly.");
}
console.log("Mail Sent!");
按照scaleway文档(https://www.scaleway.com/en/docs/webhosting/classic/how-to/check-emails/),我尝试了所有端口(25,465,587,2525)。我将主机从smtauth.online.net更改为smtp.online.net,没有任何帮助。
如果有人解决了这个问题,那将是一个很大的帮助。由于我找到解决办法了。
通过添加"name"选项
name -客户端的可选主机名,用于识别到服务器,默认为机器的主机名
let transporter = nodemailer.createTransport({
name: 'www.domain.com',
host: "smtpauth.online.net",
port: 587,
secure: false,
auth: {
user: "xxx@domain.fr",
pass: "xxx",
},
tls: {
rejectUnauthorized: false,
},
});