Skip to content

Commit e5ec252

Browse files
Pranesh RaguPranesh Ragu
authored andcommitted
email js contact component
1 parent 84e6017 commit e5ec252

3 files changed

Lines changed: 28 additions & 4 deletions

File tree

package-lock.json

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

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@
1010
"preview": "vite preview"
1111
},
1212
"dependencies": {
13+
"@emailjs/browser": "^4.4.1",
14+
"emailjs-com": "^3.2.0",
1315
"framer-motion": "^11.0.3",
1416
"react": "^18.3.1",
1517
"react-dom": "^18.3.1",
1618
"react-icons": "^5.0.1",
1719
"react-intersection-observer": "^9.5.3",
1820
"react-scroll": "^1.9.0",
19-
"react-type-animation": "^3.2.0",
20-
"emailjs-com": "^3.2.0"
21+
"react-type-animation": "^3.2.0"
2122
},
2223
"devDependencies": {
2324
"@eslint/js": "^9.9.1",
@@ -34,4 +35,4 @@
3435
"tailwindcss": "^3.4.0",
3536
"vite": "^5.4.2"
3637
}
37-
}
38+
}

src/components/sections/Contact.jsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ import SectionHeading from '../ui/SectionHeading'
33
import Button from '../ui/Button'
44
import { motion } from 'framer-motion'
55
import { FaPaperPlane, FaMapMarkerAlt, FaEnvelope, FaPhone } from 'react-icons/fa'
6+
import emailjs from '@emailjs/browser'
7+
8+
const SERVICE_ID = 'service_v1dg2s8'
9+
const TEMPLATE_ID = 'template_wtxb83p'
10+
const PUBLIC_KEY = 'GmGI_huq_ZkOqwsT5'
11+
612

713
const Contact = () => {
814
const [formData, setFormData] = useState({
@@ -33,10 +39,17 @@ const Contact = () => {
3339
info: { error: false, msg: null }
3440
})
3541

42+
const templateParams = {
43+
from_name: formData.name,
44+
from_email: formData.email,
45+
subject: formData.subject,
46+
message: formData.message
47+
}
48+
3649
try {
3750
// In a real app, we would send this data to a server or service like EmailJS
3851
// For demo purposes, we'll just simulate a successful submission
39-
await new Promise(resolve => setTimeout(resolve, 1500))
52+
await emailjs.send(SERVICE_ID, TEMPLATE_ID, templateParams, PUBLIC_KEY)
4053

4154
setStatus({
4255
submitted: true,

0 commit comments

Comments
 (0)