Skip to content

Commit 208cb76

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 19aa1a0 + fead302 commit 208cb76

File tree

15 files changed

+736
-65
lines changed

15 files changed

+736
-65
lines changed

package-lock.json

Lines changed: 165 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"@mui/material": "^5.11.15",
1818
"@mui/x-data-grid": "^6.0.4",
1919
"@mui/x-date-pickers": "^6.0.4",
20+
"@sendgrid/mail": "^7.7.0",
2021
"aos": "^2.3.4",
2122
"axios": "^1.3.5",
2223
"cheerio": "^1.0.0-rc.12",
@@ -31,6 +32,7 @@
3132
"puppeteer": "^19.8.5",
3233
"react": "18.2.0",
3334
"react-dom": "18.2.0",
35+
"react-modal": "^3.16.1",
3436
"react-otp-input": "^3.0.0",
3537
"react-spinners": "^0.13.8",
3638
"react-toastify": "^9.1.2",

server/package-lock.json

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"main": "server.js",
66
"type": "module",
77
"dependencies": {
8+
"@sendgrid/mail": "^7.7.0",
89
"@tensorflow/tfjs-node": "^4.4.0",
910
"axios": "^0.26.0",
1011
"bcrypt": "^5.1.0",

server/src/models/EmailSchema.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const mongoose = require("mongoose");
2+
3+
const emailSchema = new mongoose.Schema({
4+
emails: String,
5+
stringMsg: String,
6+
});
7+
8+
const Email = mongoose.model("Email", emailSchema);
9+
10+
module.exports = Email;

server/src/routes/sms.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import express from 'express';
22
const router = express.Router();
33

4-
import { sendOTP, verifyOTP } from "../services/smsAPI.js";
4+
import { sendOTP, verifyOTP, sendMail } from "../services/smsAPI.js";
55

66
// OTP routes
77
router.post("/apis/sendOTP", (req, res) => {
@@ -16,11 +16,11 @@ router.post("/apis/sendOTP", (req, res) => {
1616
data,
1717
});
1818

19-
sendOTP(phone)
19+
sendOTP(phone)
2020
.then(() => {
21-
res.status(200).send({
22-
message: `OTP sent to ${phone}`
23-
})
21+
res.status(200).send({
22+
message: `OTP sent to ${phone}`,
23+
});
2424
})
2525
.catch((err) => {
2626
console.log(err);
@@ -33,6 +33,9 @@ router.post("/apis/sendOTP", (req, res) => {
3333
});
3434
});
3535

36+
// sendGrid router
37+
router.post("/apis/sendEmail", sendMail);
38+
3639
// Verify Endpoint
3740
router.post("/apis/verifyOTP", (req, res) => {
3841
const phone = `+91${req.body.phone}`;
@@ -75,5 +78,4 @@ router.post("/apis/verifyOTP", (req, res) => {
7578
});
7679
});
7780

78-
79-
export default router;
81+
export default router;

server/src/services/sendEmail.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const sgMail = require("@sendgrid/mail");
2+
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
3+
4+
const msg = {
5+
to: "test@example.com", // Change to your recipient
6+
from: "test@example.com", // Change to your verified sender
7+
subject: "Sending with SendGrid is Fun",
8+
text: "and easy to do anywhere, even with Node.js",
9+
html: "<strong>and easy to do anywhere, even with Node.js</strong>",
10+
};
11+
12+
sgMail
13+
.send(msg)
14+
.then(() => {
15+
console.log("Email sent");
16+
})
17+
.catch((error) => {
18+
console.error(error);
19+
});

0 commit comments

Comments
 (0)