error Error: read ECONNRESET at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20 error in nodemailer

问题描述 投票:0回答:0

我正在尝试使用“nodemailer”发送电子邮件,但每次我都收到此错误

enter image description here

const router = require("express").Router();
const nodemailer = require("nodemailer");

router.post("/sendmail", async (req, res) => {
    const { email } = req.body;
    const transporter = nodemailer.createTransport({
        service: "gmail",
        auth: {
            user: process.env.EMAIL,
            pass: process.env.PASSWORD,
        },
    });
    const mailOptions = {
        from: process.env.EMAIL,
        to: email,
        subject: "Sending Email For password Reset",
        html: "<h1>Congratulation You successfully send Email</h1>",
    };

    transporter.sendMail(mailOptions, (error, info) => {
        if (error) {
            console.log("error", error);
        } else {
            console.log("Email sent", info.response);
            res.status(201).json({
                message: "Email sent Succsfully",
            });
        }
    });
});

module.exports = router;

这是我的代码谁能帮我解决这个问题...

mern nodemailer
© www.soinside.com 2019 - 2024. All rights reserved.