`
var transport = nodemailer.createTransport({
host: "sandbox.smtp.mailtrap.io",
port: 2525,
auth: {
user: "xxxxxx",
pass: "xxxxxx"
},
tls: {
rejectUnauthorized: false
}
});
transport.sendMail()
const mailData = {
from: '[email protected]',
to: '[email protected]',
subject: `Message From xxx`,
text: 'xxxxx',
html: `<div>Testing</div>`
}
transport.sendMail(mailData
, (error, info) => {
if (error) {
console.log(error);
} else {
console.log('Email sent: ' + info.response);
}
});
`
我使用了“nodemailer”包来发送邮件。 我使用的服务是mailTrap。
使用 nodemailer,我使用 nodemailer.createTransport 创建了传输器以及 mailtrap.io 服务凭证。
当我尝试使用 transporter.sendMail() 发送邮件时,我收到以下问题。
ReferenceError: setImmediate is not defined
整个项目已在 NextJs Typescript 中创建。
如果有人知道修复方法,请发布。提前致谢。
我需要解决上述问题的解决方案或其他在 Nextjs 中发送邮件的方法。