I am trying to send sample mail from my email to other, it is saying
{"message":"Error","error":{"errno":-4039,"code":"ESOCKET","syscall":"connect","address":"40.99.34.150","port":587,"command":"CONN"}}
The API route handler according to 13.4 is
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 });
}
}
Referred below links but were not of much help!
- Nodemailer Nextjs Typescript form not sending emails
- ETIMEDOUT connect error using nodemailer in Nodejs Openshift application
Feel free to redirect me to any other package which supports typescript and nextjs