【发布时间】:2023-02-25 14:50:41
【问题描述】:
我在我的网页上创建了一个表单,并使用 nodemailer 将电子邮件发送到我的 gmail 帐户。我使用的主机是 gmail。一切都在开发中,但是当我部署到 Vercel 时,我在使用表单时没有收到任何电子邮件。我试过 async 和 await 但它仍然不起作用。当我检查 Vercel 上的功能日志时,在某些情况下我会收到此错误
Error: Greeting never received
at SMTPConnection._formatError (/var/task/node_modules/nodemailer/lib/smtp-connection/index.js:790:19)
at SMTPConnection._onError (/var/task/node_modules/nodemailer/lib/smtp-connection/index.js:776:20)
at Timeout.<anonymous> (/var/task/node_modules/nodemailer/lib/smtp-connection/index.js:710:22)
at listOnTimeout (node:internal/timers:564:17)
at processTimers (node:internal/timers:507:7) {
code: 'ETIMEDOUT',
command: 'CONN'
}
这是我的运输车
const transporter = NodeMailer.createTransport({
service: 'gmail',
secure: true,
auth: {
user: 'fifthtribe05@gmail.com',
pass: <secretPass>
}
});
发送邮件
const mailOptions = {
from: email,
to: 'email@gmail.com',
subject: 'Subject',
text: `${message} from ${email}`
};
const sendMessage = async(mailOptions:any)=> {
await transporter.sendMail(mailOptions, function(error: any, info: { response: string; }){
console.log("sending");
console.log(error);
if (error) {
console.log(error);
} else {
console.log('Email sent: ' + info.response);
}
})};
await sendMessage(mailOptions);
请我需要帮助或者是否有任何其他选择
Ive read other similar issues on satckoverflow and github.
1. I've added async and await
2. Ive added secure true
3. it works in development but not in production (vercel)
【问题讨论】:
标签: reactjs nodemailer remix