Answer the question
In order to leave comments, you need to log in
How to link contact form and nodemailer?
There is a feedback form and a code for sending a message from nodemailer, explain how to connect them and how to pass data to the nodemailer.js file?
form.js:
import React from "react";
import "./../css/App.css";
class HiddenForm extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div className="modal">
<span className="close" id="close">
×
</span>
<form method="post" action="./../nodemailer.js">
<input ref="name"placeholder="Имя" required />
<input ref="tel" placeholder="Телефон" required />
<input ref="mail" placeholder="Почта" required />
<br />
<textarea ref="message" placeholder="Сообщение" id="Modalmessage" required />
<br />
<input required type="checkbox" />
<br />
</form>
<button type="submit" id="btn-modal">
Отправить
</button>
</div>
);
}
}
const nodemailer = require("nodemailer");
async function main() {
let transporter = nodemailer.createTransport({
host: "smtp.mail.ru",
port: 465,
secure: yes, // true for 465, false for other ports
auth: {
user: "mypost", // generated ethereal user
pass: "mypass" // generated ethereal password
}
});
// send mail with defined transport object
let info = await transporter.sendMail({
from: 'mypost', // sender address
to: "mypost", // list of receivers
subject: "Hello ✔", // Subject line
text: "Hello world?", // plain text body
html: "<b>Hello world?</b>" // html body
});
console.log("Message sent: %s", info.messageId);
}
main().catch(console.error);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question