79109820

Date: 2024-10-21 11:31:24
Score: 0.5
Natty:
Report link

Explanation in my comment...

const transporter = nodemailer.createTransport({
        host: "smtp.ionos.de",
        port: 587,
        secure: false, // true for port 465, false for other ports
        auth: {
            user: "[email protected]",
            pass: "xxxxxxxxxxxxxx",
        },
    });
    

general_users.post("/Kontakt", async(req, res, next) => {

    var content = req.body;
    content = JSON.stringify(content)

    await transporter.sendMail({
        from: "[email protected]", // sender address
        to: "[email protected]", // list of receivers
        subject: "Kundenanfrage", // Subject line
        text: content, // plain text body
        html: `<b>${content}</b>`})
        .catch((error) => {return res.status(500).json({ error: "message not sent" }).end();})
        .then(res.status(200).json({ message: "message sent" }).end())
})
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: mahas