Files
static-site/pages/api/hello.js

27 lines
791 B
JavaScript

import nodemailer from "nodemailer";
export default function handler(req, res) {
let transporter = nodemailer.createTransport({
host: "mail.wastpol.pl",
port: 465,
secure: true,
auth: {
user: "kontakt@wastpol.pl",
pass: "jHP4oCaELy0EOhz5",
},
});
let info = transporter.sendMail({
from: `"${req.body.name} 🤡" <foo@example.com>`, // sender address
to: "kontakt@wastpol.pl", // list of receivers
subject: `Wiadomość od ${req.body.name}`, // Subject line
html: `<b>Treść:</b> ${req.body.msg}<br/>
<b>Dane do kontaktu:</b><br/>
<b>nr tel: </b>${req.body.tel}<br/>
<b>mail: </b>${req.body.mail}<br/><br/>
<i>Wiadomość wygenerowana automatycznie na stronie wastpol.pl</i>`, // html body
});
res.status(200).json({ msg: "Message Sent" });
}