【发布时间】:2021-01-24 14:31:45
【问题描述】:
我有一个 api,当用户在前端提交数据时发送电子邮件。我无法让 nodemailer sendmail 工作。
nodemailer.js -
const nodemailer = require("nodemailer");
async function sendmail(data) {
let transporter = nodemailer.createTransport({
host: "www.google.com",
port: 587,
secure: false,
auth: {
user: <my email>,
pass: <password>,
},
});
await transporter.sendMail(
{
from: data.email,
to: <my email>,
subject: "CEWA Feedback",
text: data.message,
html: "<b>Hello world?</b>",
},
(err) => {
console.log(err);
}
);
}
module.exports = sendmail;
当此函数运行时,我在控制台中收到此错误 -
Error: connect ETIMEDOUT 216.58.221.36:587
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16) {
errno: 'ETIMEDOUT',
code: 'ESOCKET',
syscall: 'connect',
address: '216.58.221.36',
port: 587,
command: 'CONN'
}
知道出了什么问题吗?提前致谢。
【问题讨论】:
标签: node.js express nodemailer