Skip to content

Commit

Permalink
Email
Browse files Browse the repository at this point in the history
  • Loading branch information
AyushSharma72 committed Oct 11, 2024
1 parent fd9c9a9 commit 09bbf11
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions backend/controller/EmailController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const nodemailer = require("nodemailer");

async function SendEmailController(req, resp) {
const transporter = nodemailer.createTransport({
service: "gmail",
auth: {
user: "[email protected]", // youe email
pass: "password", // your password
},
});

const mailOptions = {
from: "[email protected]",
to: "[email protected]", // email where you want to receive the message
subject: "New From Collect your GamingTools",
text: `
Name: ${req.body.Name}
Email: ${req.body.Email}
Message: ${req.body.Message}`,
};

transporter.sendMail(mailOptions, (error, info) => {
if (error) {
console.log("Error sending email: " + error);
resp.status(500).send("Error sending email");
} else {
console.log("Email sent: " + info.response);
resp.status(200).send("Form data sent successfully");
}
});
}

module.exports = { SendEmailController };

0 comments on commit 09bbf11

Please sign in to comment.