我正在尝试将示例邮件从我的电子邮件发送给其他人,它说
{"message":"Error","error":{"errno":-4039,"code":"ESOCKET","syscall":"connect","address":"40.99.34.150","port":587,"command":"CONN"}}
根据 13.4 的 API 路由处理程序是
export async function GET(request: NextRequest) {
const transporter = nodemailer.createTransport({
service: "gmail",
auth: {
user: "<my-email>",
pass: "<valid-password-of-the-above-email>",
},
});
const data = {
from: "<my-email>",
to: "<other-email>",
text: "What",
html: "<html><body>hello</body></html>",
subject: "hello",
};
try {
await transporter.sendMail(data);
return NextResponse.json({ message: "OK" }, { status: 200 });
} catch (error) {
return NextResponse.json({ message: "Error", error }, { status: 500 });
}
}
参考了下面的链接,但没有太大帮助!
请随意将我重定向到任何其他支持 typescript 和 nextjs 的包