-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd9c9a9
commit 09bbf11
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |