diff --git a/api/send-email.js b/api/send-email.js
new file mode 100644
index 0000000..c615e6c
--- /dev/null
+++ b/api/send-email.js
@@ -0,0 +1,69 @@
+const express = require('express');
+const axios = require('axios');
+const bodyParser = require('body-parser');
+const cors = require('cors'); // Import CORS
+const app = express();
+const port = process.env.PORT || 5001; // Ensure this matches the port in setupProxy.js
+
+app.use(cors()); // Use CORS middleware
+app.use(bodyParser.json());
+
+app.post('/send-email', async (req, res) => {
+ const { book, chapter, suggestedTitle, chapterSubtitles, keywords, proposal, authors } = req.body;
+
+ const htmlbody = `
+
+
Book Proposal Submission
+
Book: ${book}
+
Chapter: ${chapter}
+
Suggested Chapter Title: ${suggestedTitle}
+
Chapter Subtitles: ${chapterSubtitles}
+
Keywords: ${keywords}
+
Proposal: ${proposal}
+
Authors:
+ ${authors.map((author, index) => `
+
+
Author ${index + 1}
+
Name: ${author.name}
+
Email: ${author.email}
+
Department: ${author.department}
+
Institution: ${author.institution}
+
Corresponding Author: ${author.isCorresponding ? "Yes" : "No"}
+
+ `).join('')}
+
+ `;
+
+ try {
+ const response = await axios.post('https://api.zeptomail.com/v1.1/email', {
+ from: {
+ address: "contact@narayanvyas.com",
+ name: "contact"
+ },
+ to: [
+ {
+ email_address: {
+ address: "admin@narayanvyas.com",
+ name: "Narayan"
+ }
+ }
+ ],
+ subject: "Book Proposal Submission",
+ htmlbody: htmlbody,
+ }, {
+ headers: {
+ 'Content-Type': 'application/json',
+ 'Authorization': `Zoho-enczapikey wSsVR60nq0X1WP16z2WvJuc7mw9XBVLxFBkv3lSl7Xb/T63FoMdvlEXGDFeuSfcfEmVsFWQW8rl8yxcH2jENiYkqywwGWyiF9mqRe1U4J3x17qnvhDzIXmVYlRKBL4kBxQ9tkmJhGski+g==`
+ }
+ });
+
+ res.status(200).send(response.data);
+ } catch (error) {
+ console.error("Error sending email:", error.message);
+ res.status(500).send({ error: 'Error sending email' });
+ }
+});
+
+app.listen(port, () => {
+ console.log(`Server running at http://localhost:${port}`);
+});
diff --git a/package.json b/package.json
index 6876718..4ea4d1c 100644
--- a/package.json
+++ b/package.json
@@ -14,10 +14,14 @@
"animate.css": "^4.1.1",
"axios": "^1.7.2",
"bootstrap": "^5.2.3",
+ "concurrently": "^8.2.2",
"core-js": "^3.27.1",
+ "cors": "^2.8.5",
"emailjs-com": "^3.2.0",
+ "express": "^4.19.2",
"framer-motion": "^10.6.0",
"gsap": "^3.11.5",
+ "http-proxy-middleware": "^3.0.0",
"jquery": "^3.6.4",
"react": "^18.2.0",
"react-accessible-accordion": "^5.0.0",
@@ -42,7 +46,7 @@
"zeptomail": "^6.0.0"
},
"scripts": {
- "start": "react-scripts start",
+ "start": "concurrently \"react-scripts start\" \"node api/send-email.js\"",
"dev": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
diff --git a/src/components/Contact/emailService.js b/src/components/Contact/emailService.js
index ca777e8..51d0251 100644
--- a/src/components/Contact/emailService.js
+++ b/src/components/Contact/emailService.js
@@ -1,58 +1,18 @@
// emailService.js
-import { SendMailClient } from "zeptomail";
-
-const url = "https://api.zeptomail.com/";
-const token = "Zoho-enczapikey wSsVR60nq0X1WP16z2WvJuc7mw9XBVLxFBkv3lSl7Xb/T63FoMdvlEXGDFeuSfcfEmVsFWQW8rl8yxcH2jENiYkqywwGWyiF9mqRe1U4J3x17qnvhDzIXmVYlRKBL4kBxQ9tkmJhGski+g==";
-
-const client = new SendMailClient({ url, token });
-
const sendEmail = async (formData) => {
- const { book, chapter, suggestedTitle, chapterSubtitles, keywords, proposal, authors } = formData;
-
- const htmlbody = `
-
-
Book Proposal Submission
-
Book: ${book}
-
Chapter: ${chapter}
-
Suggested Chapter Title: ${suggestedTitle}
-
Chapter Subtitles: ${chapterSubtitles}
-
Keywords: ${keywords}
-
Proposal: ${proposal}
-
Authors:
- ${authors.map((author, index) => `
-
-
Author ${index + 1}
-
Name: ${author.name}
-
Email: ${author.email}
-
Department: ${author.department}
-
Institution: ${author.institution}
-
Corresponding Author: ${author.isCorresponding ? "Yes" : "No"}
-
- `).join('')}
-
- `;
-
try {
- const resp = await client.sendMail({
- from: {
- address: "contact@narayanvyas.com",
- name: "contact"
+ const response = await fetch('/send-email', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
},
- to: [
- {
- email_address: {
- address: "admin@narayanvyas.com",
- name: "Narayan"
- }
- }
- ],
- subject: "Book Proposal Submission",
- htmlbody: htmlbody,
+ body: JSON.stringify(formData),
});
- console.log("Email sent successfully:", resp);
+ const result = await response.json();
+ console.log("Email sent successfully:", result);
} catch (error) {
- console.error("Error sending email:", error.message, error.code, error.response ? error.response.data : 'No response data');
+ console.error("Error sending email:", error);
}
};
diff --git a/src/pages/books/BookProposalFormContainer.js b/src/pages/books/BookProposalFormContainer.js
index ce9620b..10aa752 100644
--- a/src/pages/books/BookProposalFormContainer.js
+++ b/src/pages/books/BookProposalFormContainer.js
@@ -62,7 +62,6 @@ const BookProposalFormContainer = (props) => {
try {
await sendEmail(formData);
- e.target.reset();
setAuthors([{ name: '', email: '', department: '', institution: '', isCorresponding: true }]); // Reset authors
} catch (error) {
console.error("Error submitting proposal:", error);
diff --git a/src/setupProxy.js b/src/setupProxy.js
new file mode 100644
index 0000000..647fa8d
--- /dev/null
+++ b/src/setupProxy.js
@@ -0,0 +1,18 @@
+const { createProxyMiddleware } = require('http-proxy-middleware');
+
+module.exports = function (app) {
+ console.log('Setting up proxy for /send-email');
+ app.use(
+ '/send-email',
+ createProxyMiddleware({
+ target: 'http://localhost:5001', // Ensure this is the correct port for your Express server
+ changeOrigin: true,
+ onProxyReq: (proxyReq, req, res) => {
+ console.log('Proxying request:', req.method, req.url);
+ },
+ onError: (err, req, res) => {
+ console.error('Proxy error:', err);
+ }
+ })
+ );
+};
diff --git a/vercel.js b/vercel.js
new file mode 100644
index 0000000..2855553
--- /dev/null
+++ b/vercel.js
@@ -0,0 +1,8 @@
+{
+ "rewrites": [
+ {
+ "source": "/send-email",
+ "destination": "/api/send-email"
+ }
+ ]
+}
diff --git a/yarn.lock b/yarn.lock
index 586eec2..b7dac81 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1125,7 +1125,7 @@
resolved "https://registry.npmjs.org/@babel/regjsgen/-/regjsgen-0.8.0.tgz"
integrity sha512-x/rqGMdzj+fWZvCOYForTghzbtqPDZ5gPwaoNGHdgDfF2QA/XZbCBp4Moo5scrkAMPhB7z26XM/AaHuIJdgauA==
-"@babel/runtime@^7.11.2", "@babel/runtime@^7.12.5", "@babel/runtime@^7.16.3", "@babel/runtime@^7.18.3", "@babel/runtime@^7.23.2", "@babel/runtime@^7.23.9", "@babel/runtime@^7.5.5", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2":
+"@babel/runtime@^7.11.2", "@babel/runtime@^7.12.5", "@babel/runtime@^7.16.3", "@babel/runtime@^7.18.3", "@babel/runtime@^7.21.0", "@babel/runtime@^7.23.2", "@babel/runtime@^7.23.9", "@babel/runtime@^7.5.5", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2":
version "7.24.6"
resolved "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.6.tgz"
integrity sha512-Ja18XcETdEl5mzzACGd+DKgaGJzPTCow7EglgwTmHdwokzDFYh/MHua6lU6DV/hjF2IaOJ4oX2nqnjG7RElKOw==
@@ -2274,7 +2274,7 @@
resolved "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.4.tgz"
integrity sha512-D0CFMMtydbJAegzOyHjtiKPLlvnm3iTZyZRSZoLq2mRhDdmLfIWOCYPfQJ4cu2erKghU++QvjcUjp/5h7hESpA==
-"@types/http-proxy@^1.17.8":
+"@types/http-proxy@^1.17.10", "@types/http-proxy@^1.17.8":
version "1.17.14"
resolved "https://registry.npmjs.org/@types/http-proxy/-/http-proxy-1.17.14.tgz"
integrity sha512-SSrD0c1OQzlFX7pGu1eXxSEjemej64aaNPRhhVYUGqXh0BtldAAx37MG8btcumvpgKyZp1F5Gn3JkktdxiFv6w==
@@ -3520,6 +3520,15 @@ cliui@^7.0.2:
strip-ansi "^6.0.0"
wrap-ansi "^7.0.0"
+cliui@^8.0.1:
+ version "8.0.1"
+ resolved "https://registry.yarnpkg.com/cliui/-/cliui-8.0.1.tgz#0c04b075db02cbfe60dc8e6cf2f5486b1a3608aa"
+ integrity sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==
+ dependencies:
+ string-width "^4.2.0"
+ strip-ansi "^6.0.1"
+ wrap-ansi "^7.0.0"
+
clsx@^2.0.0, clsx@^2.1.0:
version "2.1.1"
resolved "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz"
@@ -3640,6 +3649,21 @@ concat-map@0.0.1:
resolved "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz"
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
+concurrently@^8.2.2:
+ version "8.2.2"
+ resolved "https://registry.yarnpkg.com/concurrently/-/concurrently-8.2.2.tgz#353141985c198cfa5e4a3ef90082c336b5851784"
+ integrity sha512-1dP4gpXFhei8IOtlXRE/T/4H88ElHgTiUzh71YUmtjTEHMSRS2Z/fgOxHSxxusGHogsRfxNq1vyAwxSC+EVyDg==
+ dependencies:
+ chalk "^4.1.2"
+ date-fns "^2.30.0"
+ lodash "^4.17.21"
+ rxjs "^7.8.1"
+ shell-quote "^1.8.1"
+ spawn-command "0.0.2"
+ supports-color "^8.1.1"
+ tree-kill "^1.2.2"
+ yargs "^17.7.2"
+
confusing-browser-globals@^1.0.11:
version "1.0.11"
resolved "https://registry.npmjs.org/confusing-browser-globals/-/confusing-browser-globals-1.0.11.tgz"
@@ -3704,6 +3728,14 @@ core-util-is@~1.0.0:
resolved "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz"
integrity sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==
+cors@^2.8.5:
+ version "2.8.5"
+ resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.5.tgz#eac11da51592dd86b9f06f6e7ac293b3df875d29"
+ integrity sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==
+ dependencies:
+ object-assign "^4"
+ vary "^1"
+
cosmiconfig@^6.0.0:
version "6.0.0"
resolved "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-6.0.0.tgz"
@@ -3981,6 +4013,13 @@ data-view-byte-offset@^1.0.0:
es-errors "^1.3.0"
is-data-view "^1.0.1"
+date-fns@^2.30.0:
+ version "2.30.0"
+ resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.30.0.tgz#f367e644839ff57894ec6ac480de40cae4b0f4d0"
+ integrity sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==
+ dependencies:
+ "@babel/runtime" "^7.21.0"
+
debug@2.6.9, debug@^2.6.0:
version "2.6.9"
resolved "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz"
@@ -4835,9 +4874,9 @@ expect@^27.5.1:
jest-matcher-utils "^27.5.1"
jest-message-util "^27.5.1"
-express@^4.17.3:
+express@^4.17.3, express@^4.19.2:
version "4.19.2"
- resolved "https://registry.npmjs.org/express/-/express-4.19.2.tgz"
+ resolved "https://registry.yarnpkg.com/express/-/express-4.19.2.tgz#e25437827a3aa7f2a827bc8171bbbb664a356465"
integrity sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==
dependencies:
accepts "~1.3.8"
@@ -5501,6 +5540,18 @@ http-proxy-middleware@^2.0.3:
is-plain-obj "^3.0.0"
micromatch "^4.0.2"
+http-proxy-middleware@^3.0.0:
+ version "3.0.0"
+ resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-3.0.0.tgz#550790357d6f92a9b82ab2d63e07343a791cf26b"
+ integrity sha512-36AV1fIaI2cWRzHo+rbcxhe3M3jUDCNzc4D5zRl57sEWRAxdXYtw7FSQKYY6PDKssiAKjLYypbssHk+xs/kMXw==
+ dependencies:
+ "@types/http-proxy" "^1.17.10"
+ debug "^4.3.4"
+ http-proxy "^1.18.1"
+ is-glob "^4.0.1"
+ is-plain-obj "^3.0.0"
+ micromatch "^4.0.5"
+
http-proxy@^1.18.1:
version "1.18.1"
resolved "https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.1.tgz"
@@ -7067,7 +7118,7 @@ nwsapi@^2.2.0:
resolved "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.10.tgz"
integrity sha512-QK0sRs7MKv0tKe1+5uZIQk/C8XGza4DAnztJG8iD+TpJIORARrCxczA738awHrZoHeTjSSoHqao2teO0dC/gFQ==
-object-assign@^4.0.1, object-assign@^4.1.1:
+object-assign@^4, object-assign@^4.0.1, object-assign@^4.1.1:
version "4.1.1"
resolved "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz"
integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=
@@ -8589,6 +8640,13 @@ run-parallel@^1.1.9:
dependencies:
queue-microtask "^1.2.2"
+rxjs@^7.8.1:
+ version "7.8.1"
+ resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.8.1.tgz#6f6f3d99ea8044291efd92e7c7fcf562c4057543"
+ integrity sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==
+ dependencies:
+ tslib "^2.1.0"
+
safe-array-concat@^1.1.2:
version "1.1.2"
resolved "https://registry.npmjs.org/safe-array-concat/-/safe-array-concat-1.1.2.tgz"
@@ -8927,6 +8985,11 @@ sourcemap-codec@^1.4.8:
resolved "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz"
integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==
+spawn-command@0.0.2:
+ version "0.0.2"
+ resolved "https://registry.yarnpkg.com/spawn-command/-/spawn-command-0.0.2.tgz#9544e1a43ca045f8531aac1a48cb29bdae62338e"
+ integrity sha512-zC8zGoGkmc8J9ndvml8Xksr1Amk9qBujgbF0JAIWO7kXr43w0h/0GJNM/Vustixu+YE8N/MTrQ7N31FvHUACxQ==
+
spdy-transport@^3.0.0:
version "3.0.0"
resolved "https://registry.npmjs.org/spdy-transport/-/spdy-transport-3.0.0.tgz"
@@ -9034,7 +9097,7 @@ string-natural-compare@^3.0.1:
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"
-string-width@^4.1.0, string-width@^4.2.0:
+string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -9219,7 +9282,7 @@ supports-color@^7.0.0, supports-color@^7.1.0:
dependencies:
has-flag "^4.0.0"
-supports-color@^8.0.0:
+supports-color@^8.0.0, supports-color@^8.1.1:
version "8.1.1"
resolved "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz"
integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==
@@ -9459,6 +9522,11 @@ tr46@~0.0.3:
resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a"
integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==
+tree-kill@^1.2.2:
+ version "1.2.2"
+ resolved "https://registry.yarnpkg.com/tree-kill/-/tree-kill-1.2.2.tgz#4ca09a9092c88b73a7cdc5e8a01b507b0790a0cc"
+ integrity sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==
+
tryer@^1.0.1:
version "1.0.1"
resolved "https://registry.npmjs.org/tryer/-/tryer-1.0.1.tgz"
@@ -9484,7 +9552,7 @@ tslib@^1.8.1:
resolved "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz"
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==
-tslib@^2.0.3, tslib@^2.4.0:
+tslib@^2.0.3, tslib@^2.1.0, tslib@^2.4.0:
version "2.6.2"
resolved "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz"
integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==
@@ -9714,7 +9782,7 @@ v8-to-istanbul@^8.1.0:
convert-source-map "^1.6.0"
source-map "^0.7.3"
-vary@~1.1.2:
+vary@^1, vary@~1.1.2:
version "1.1.2"
resolved "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz"
integrity sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==
@@ -10275,6 +10343,11 @@ yargs-parser@^20.2.2:
resolved "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz"
integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==
+yargs-parser@^21.1.1:
+ version "21.1.1"
+ resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35"
+ integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==
+
yargs@^16.2.0:
version "16.2.0"
resolved "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz"
@@ -10288,6 +10361,19 @@ yargs@^16.2.0:
y18n "^5.0.5"
yargs-parser "^20.2.2"
+yargs@^17.7.2:
+ version "17.7.2"
+ resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.7.2.tgz#991df39aca675a192b816e1e0363f9d75d2aa269"
+ integrity sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==
+ dependencies:
+ cliui "^8.0.1"
+ escalade "^3.1.1"
+ get-caller-file "^2.0.5"
+ require-directory "^2.1.1"
+ string-width "^4.2.3"
+ y18n "^5.0.5"
+ yargs-parser "^21.1.1"
+
yocto-queue@^0.1.0:
version "0.1.0"
resolved "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz"