我有一个自定义smtp主机,它不需要任何身份验证(仅限于内部使用,需要在虚拟专用网上),而且我无法让它与NodeMailer一起工作。
目前我正在做
const nodemailer = require("nodemailer");
let transporter = nodemailer.createTransport({
host: "customHost.com",
port: 587,
secure: false, // upgrade later with STARTTLS
});
let info = transporter.sendMail({
from: 'from-email@example.com',
to: 'foo@example.com',
subject: 'Hello!',
html: 'This is a test',
});
console.log("Message sent: %s", info.messageId);这会导致
Error: connect ETIMEDOUT 10.48.1.36:587
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1157:16) {
errno: -60,
code: 'ESOCKET',
syscall: 'connect',
address: '10.48.1.36',
port: 587,
command: 'CONN'
}我能够在smtp-客户端中实现这一点,但是这个库似乎不支持发送HTML,这是我所需要的。
是否有人能够让无版权主机使用NodeMailer?
发布于 2022-05-31 17:52:06
经过更多的追逐,我终于解决了这个问题。
我认为在默认情况下,nodemailer使用端口587 (当然我也定义了它,但即使删除该行也不起作用),所以我不得不重写它来默认使用端口25。此外,我必须设置它来接受自签署的证书。我的运输机现在看起来就像
let transporter = nodemailer.createTransport({
host: "customHost.com",
port: 25,
secure: false, // upgrade later with STARTTLS
tls: {
rejectUnauthorized: false
}
});https://stackoverflow.com/questions/72451908
复制相似问题