Skip to content

Commit f0d748d

Browse files
committed
feat(contact): implement EmailJS contact form with reCAPTCHA validation
- Add EmailJS integration for contact form submissions - Implement reCAPTCHA v3 Enterprise for spam protection - Enhance form validation with loading states and error handling - Add comprehensive setup documentation (EMAILJS_SETUP.md) - Configure environment variables for EmailJS and reCAPTCHA - Update dependencies: @emailjs/browser and @google-cloud/recaptcha-enterprise - Make Discord field optional and improve UX feedback - Add form state management (submitting, success, error states) The contact form now supports real email sending via EmailJS service with enterprise-grade reCAPTCHA protection, providing a secure and professional contact experience for the portfolio website.
1 parent d1f93a4 commit f0d748d

13 files changed

Lines changed: 1938 additions & 34 deletions

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ coverage
2929

3030
*.tsbuildinfo
3131

32-
.vite-inspect
32+
.vite-inspect
33+
.env

EMAILJS_SETUP.md

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# EmailJS Setup Guide for Contact Form
2+
3+
This guide will help you set up EmailJS to enable real email sending from the contact form in your portfolio.
4+
5+
## What is EmailJS?
6+
7+
EmailJS is a service that allows you to send emails directly from the frontend without needing a backend server. Perfect for static websites and portfolios!
8+
9+
## Setup Instructions
10+
11+
### Step 1: Create EmailJS Account
12+
13+
1. Go to [EmailJS.com](https://www.emailjs.com/)
14+
2. Sign up for a free account
15+
3. Verify your email address
16+
17+
### Step 2: Add Email Service
18+
19+
1. In your EmailJS dashboard, go to **"Email Services"**
20+
2. Click **"Add New Service"**
21+
3. Choose your email provider (Gmail, Outlook, Yahoo, etc.)
22+
4. Follow the authentication steps to connect your email account
23+
5. **Note down the Service ID** (e.g., `service_abc123`)
24+
25+
### Step 3: Create Email Template
26+
27+
1. Go to **"Email Templates"**
28+
2. Click **"Create New Template"**
29+
3. Use this template structure:
30+
31+
```
32+
Subject: New Portfolio Contact from {{from_name}}
33+
34+
Hi Involvex,
35+
36+
You have received a new message from your portfolio contact form:
37+
38+
👤 Contact Details:
39+
• Name: {{from_name}}
40+
• Email: {{from_email}}
41+
• Discord: {{discord_name}}
42+
43+
📝 Message:
44+
{{message}}
45+
46+
---
47+
This message was sent from your portfolio website.
48+
```
49+
50+
4. **Note down the Template ID** (e.g., `template_xyz789`)
51+
52+
### Step 4: Get Public Key
53+
54+
1. Go to **"Account"****"General"**
55+
2. Copy your **"Public Key"** (e.g., `user_def456`)
56+
57+
### Step 5: Configure Environment Variables
58+
59+
1. Copy the `.env.example` file to `.env`:
60+
```bash
61+
cp .env.example .env
62+
```
63+
64+
2. Edit the `.env` file and replace the placeholder values:
65+
```env
66+
VITE_EMAILJS_SERVICE_ID=service_abc123
67+
VITE_EMAILJS_TEMPLATE_ID=template_xyz789
68+
VITE_EMAILJS_PUBLIC_KEY=user_def456
69+
```
70+
71+
### Step 6: Test the Setup
72+
73+
1. Start your development server:
74+
```bash
75+
npm run dev
76+
```
77+
78+
2. Go to the contact section of your portfolio
79+
3. Fill out the form and submit
80+
4. Check your email for the test message
81+
82+
## Free Plan Limits
83+
84+
EmailJS free plan includes:
85+
- 200 emails per month
86+
- 50 emails per day
87+
- Unlimited email templates
88+
89+
## Troubleshooting
90+
91+
### Common Issues
92+
93+
1. **"Failed to send message" error**
94+
- Check that your environment variables are correctly set
95+
- Verify your email service is properly connected
96+
- Ensure your template ID is correct
97+
98+
2. **Template variables not working**
99+
- Make sure your template uses the exact variable names: `{{from_name}}`, `{{from_email}}`, `{{discord_name}}`, `{{message}}`
100+
- Check that the template is saved and published
101+
102+
3. **Authentication issues**
103+
- Reconnect your email service in the EmailJS dashboard
104+
- Check if your email provider requires app-specific passwords
105+
106+
### Debug Mode
107+
108+
To enable debug logging, add this to your `.env` file:
109+
```env
110+
VITE_EMAILJS_DEBUG=true
111+
```
112+
113+
## Alternative Email Services
114+
115+
If you prefer not to use EmailJS, consider these alternatives:
116+
117+
1. **Formspree**: Simple form handling service
118+
2. **Netlify Forms**: If deploying to Netlify
119+
3. **Getform**: Another form backend service
120+
4. **Direct SMTP**: Using nodemailer with a backend
121+
122+
## Security Notes
123+
124+
- Never expose your EmailJS private keys (only public keys are safe for frontend)
125+
- The free plan has rate limiting to prevent abuse
126+
- Consider implementing CAPTCHA for production use
127+
- Monitor your email sending to stay within limits
128+
129+
## Support
130+
131+
- [EmailJS Documentation](https://www.emailjs.com/docs/)
132+
- [EmailJS Support](https://www.emailjs.com/support/)
133+
- [Vue.js Contact Form Tutorial](https://www.emailjs.com/docs/vuejs-contact-form/)
134+
135+
---
136+
137+
**Note**: This setup enables real email sending from your portfolio. Make sure to test thoroughly and monitor your usage to stay within the free plan limits.

cspell.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"version": "0.2",
3+
"language": "en",
4+
"words": [
5+
"discordname",
6+
"EMAILJS",
7+
"Grecaptcha",
8+
"grecaptcha",
9+
"RECAPTCHA",
10+
"VITE",
11+
"recaptcha"
12+
],
13+
"ignorePaths": [
14+
"node_modules/**",
15+
"dist/**",
16+
"coverage/**",
17+
"**/*.js",
18+
"**/*.json"
19+
]
20+
}

env.d.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,14 @@
11
/// <reference types="vite/client" />
2+
3+
interface ImportMetaEnv {
4+
readonly VITE_EMAILJS_SERVICE_ID: string
5+
readonly VITE_EMAILJS_TEMPLATE_ID: string
6+
readonly VITE_EMAILJS_PUBLIC_KEY: string
7+
readonly VITE_EMAILJS_DEBUG: string
8+
readonly VITE_RECAPTCHA_PROJECTID: string
9+
readonly VITE_RECAPTCHA_SITEKEY: string
10+
}
11+
12+
interface ImportMeta {
13+
readonly env: ImportMetaEnv
14+
}

index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
<head>
44
<meta charset="UTF-8" />
55
<link rel="icon" href="/icon.png" />
6-
<script src="http://localhost:8098"></script>
6+
<!-- reCAPTCHA v3 Enterprise -->
7+
<script src="https://www.google.com/recaptcha/enterprise.js?render=6LecbjksAAAAAJCp4NMbtNEHucXwiyhMjMWpXwhZ"></script>
8+
9+
710
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
811
<title>Involvex Portfolio</title>
912
</head>

0 commit comments

Comments
 (0)