(node:1964005) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:1964005) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
exports.sendEmail = async (req, res) => {
const outputMessage = `
<h1>Mail Details</h1>
<ul>
<li>Name: ${req.body.name} </li>
<li>Email: ${req.body.email} </li>
<li>Phone: ${req.body.phone} </li>
</ul>
<h1>Message</h1>
<p>${req.body.message}</p>
`
let transporter = nodemailer.createTransport({
host: "smtp.gmail.com",
port: 465,
secure: true,
auth: {
user: "", // gmail account
pass: "", // gmail password
}
});
// send mail with defined transport object
let info = await transporter.sendMail({
from: ' "info" <...@gmail.com>', // sender address
to: ".....@windowslive.com", // list of receivers
subject: "info✔", // Subject line
html: outputMessage, // html body
});
res.status(200).redirect('/');
};