Nodemailer 不发送电子邮件
Nodemailer not sending email
我刚刚用联系表格设置了我的故障项目,我试图让它在有人填写表格时向我发送电子邮件。我遇到的问题是服务器在控制台登录消息已发送且没有错误,但我从未收到电子邮件。您可以在 https://glitch.com/edit/#!/gamesalt-dev?path=packages%2FPOSTroutes.js%3A2%3A39 and the contact form can be found at https://gamesalt-dev.glitch.me/.
找到代码
let account = {
user: "some.name@ethereal.email",
pass: "************"
}
let transporter = nodemailer.createTransport({
host: "smtp.ethereal.email",
port: 587,
secure: false,
auth: {
user: account.user,
pass: account.pass,
},
});
let mailOptions = {
from: `"Contact" <${account.user}>`,
to: "some.name@example.com",
subject: "New Contact!",
text: "Hello world",
html: "<b>Hello world</b>",
}
let info = await transporter.sendMail(mailOptions, (error, info) => {
if(error) return console.log(error);
console.log("Message sent: %s", info.messageId);
console.log("Preview URL: %s", nodemailer.getTestMessageUrl(info));
});
Ethereal is a fake SMTP service, mostly aimed at Nodemailer users (but not limited to). It's a completely free anti-transactional email service where messages never get delivered.
Instead, you can generate a vanity email account right from Nodemailer, send an email using that account just as you would with any other SMTP provider and finally preview the sent message here as no emails are actually delivered.
即使没有,the server logs in console that the message has been sent with no errors
您收到的消息是 SMTP 服务器已成功接受您的邮件并将其添加到发送队列,但这并不能保证一定会送达。接收 SMTP 服务器仍然可以拒绝它并发回退回邮件。
我刚刚用联系表格设置了我的故障项目,我试图让它在有人填写表格时向我发送电子邮件。我遇到的问题是服务器在控制台登录消息已发送且没有错误,但我从未收到电子邮件。您可以在 https://glitch.com/edit/#!/gamesalt-dev?path=packages%2FPOSTroutes.js%3A2%3A39 and the contact form can be found at https://gamesalt-dev.glitch.me/.
找到代码let account = {
user: "some.name@ethereal.email",
pass: "************"
}
let transporter = nodemailer.createTransport({
host: "smtp.ethereal.email",
port: 587,
secure: false,
auth: {
user: account.user,
pass: account.pass,
},
});
let mailOptions = {
from: `"Contact" <${account.user}>`,
to: "some.name@example.com",
subject: "New Contact!",
text: "Hello world",
html: "<b>Hello world</b>",
}
let info = await transporter.sendMail(mailOptions, (error, info) => {
if(error) return console.log(error);
console.log("Message sent: %s", info.messageId);
console.log("Preview URL: %s", nodemailer.getTestMessageUrl(info));
});
Ethereal is a fake SMTP service, mostly aimed at Nodemailer users (but not limited to). It's a completely free anti-transactional email service where messages never get delivered.
Instead, you can generate a vanity email account right from Nodemailer, send an email using that account just as you would with any other SMTP provider and finally preview the sent message here as no emails are actually delivered.
即使没有,the server logs in console that the message has been sent with no errors
您收到的消息是 SMTP 服务器已成功接受您的邮件并将其添加到发送队列,但这并不能保证一定会送达。接收 SMTP 服务器仍然可以拒绝它并发回退回邮件。