Skip to content

Commit 93085de

Browse files
committed
feat(contact): add comprehensive debugging and troubleshooting
- Add detailed console logging for EmailJS debugging - Improve error handling with specific error messages - Create comprehensive troubleshooting guide - Add step-by-step EmailJS configuration instructions - Include alternative solutions and quick fixes - Better error detection for reCAPTCHA and 400 errors - Enhanced debugging information for troubleshooting
1 parent b618440 commit 93085de

File tree

2 files changed

+154
-15
lines changed

2 files changed

+154
-15
lines changed

EMAILJS_TROUBLESHOOTING.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# EmailJS Troubleshooting Guide
2+
3+
## 🚨 Current Issue: 400 Bad Request Error
4+
5+
Your EmailJS service is returning a 400 error, which means there's a configuration issue.
6+
7+
## 🔍 Step-by-Step Troubleshooting
8+
9+
### Step 1: Check EmailJS Service Configuration
10+
11+
1. **Go to EmailJS Dashboard**: https://dashboard.emailjs.com/
12+
2. **Navigate to**: Email Services
13+
3. **Click on**: `service_vdkx6od`
14+
4. **Check these settings**:
15+
16+
#### ✅ Service Status
17+
- Make sure the service is **Active**
18+
- Verify Gmail connection is working
19+
20+
#### ✅ reCAPTCHA Settings
21+
- **Disable** reCAPTCHA completely
22+
- Look for "Security" or "reCAPTCHA" options
23+
- Turn off any captcha protection
24+
25+
#### ✅ Template Configuration
26+
- Go to "Email Templates"
27+
- Click on `template_8u7ryea`
28+
- Verify template variables match:
29+
- `{{from_name}}`
30+
- `{{from_email}}`
31+
- `{{message}}`
32+
- `{{to_email}}`
33+
- `{{subject}}`
34+
35+
### Step 2: Verify Template Variables
36+
37+
Your template should have these variables:
38+
```html
39+
Name: {{from_name}}
40+
Email: {{from_email}}
41+
Message: {{message}}
42+
```
43+
44+
### Step 3: Test EmailJS Service
45+
46+
1. **In EmailJS Dashboard**:
47+
- Go to "Email Services"
48+
- Click "Test" on your service
49+
- Send a test email
50+
51+
2. **Check if test email arrives**:
52+
- If test fails → Service configuration issue
53+
- If test succeeds → Template or code issue
54+
55+
### Step 4: Alternative Solutions
56+
57+
#### Option A: Create New Service
58+
1. Delete current service
59+
2. Create new Gmail service
60+
3. Get new Service ID
61+
4. Update code with new ID
62+
63+
#### Option B: Use Different Email Provider
64+
1. Try Outlook/Hotmail instead of Gmail
65+
2. Or use EmailJS's built-in email service
66+
67+
#### Option C: Check Gmail Settings
68+
1. Enable "Less secure app access" in Gmail
69+
2. Or use Gmail App Password
70+
3. Verify Gmail account is active
71+
72+
## 🔧 Quick Fixes to Try
73+
74+
### Fix 1: Update Service ID
75+
If you created a new service, update this line:
76+
```typescript
77+
const result = await emailjs.send(
78+
'YOUR_NEW_SERVICE_ID', // Replace with new service ID
79+
'template_8u7ryea',
80+
templateParams,
81+
'q2ic3TavT5Sv1CTEP'
82+
);
83+
```
84+
85+
### Fix 2: Update Template ID
86+
If you created a new template, update this line:
87+
```typescript
88+
const result = await emailjs.send(
89+
'service_vdkx6od',
90+
'YOUR_NEW_TEMPLATE_ID', // Replace with new template ID
91+
templateParams,
92+
'q2ic3TavT5Sv1CTEP'
93+
);
94+
```
95+
96+
### Fix 3: Check Public Key
97+
Verify your public key is correct:
98+
```typescript
99+
emailjs.init("q2ic3TavT5Sv1CTEP"); // Should match your actual public key
100+
```
101+
102+
## 🎯 Most Likely Solutions
103+
104+
1. **Disable reCAPTCHA** (90% of cases)
105+
2. **Check template variables** (5% of cases)
106+
3. **Recreate service** (5% of cases)
107+
108+
## 📞 Need Help?
109+
110+
If none of these work:
111+
1. Check EmailJS documentation
112+
2. Contact EmailJS support
113+
3. Consider alternative email services (Formspree, Netlify Forms)
114+
115+
## 🚀 After Fixing
116+
117+
Once resolved:
118+
1. Test the contact form
119+
2. Verify emails arrive in your inbox
120+
3. Check spam folder if needed
121+
4. Update the guide with what worked
122+
123+
Your contact form will work perfectly once the configuration is correct! 🎉

src/components/Contact.tsx

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ const Contact: React.FC = () => {
6565
};
6666

6767
// Send email using EmailJS (without reCAPTCHA)
68+
console.log('Sending email with params:', templateParams);
69+
6870
const result = await emailjs.send(
6971
'service_vdkx6od',
7072
'template_8u7ryea',
@@ -98,27 +100,41 @@ const Contact: React.FC = () => {
98100
} catch (error) {
99101
console.error('Error sending email:', error);
100102

101-
// Check for reCAPTCHA error
102-
if (error instanceof Error && error.message.includes('reCAPTCHA')) {
103-
setSnackbar({
104-
isOpen: true,
105-
message: 'Email service configuration error. Please contact the site administrator.',
106-
type: 'error',
107-
});
108-
} else {
109-
setSnackbar({
110-
isOpen: true,
111-
message: 'Network error. Please check your connection and try again.',
112-
type: 'error',
113-
});
114-
}
103+
// Log the full error object for debugging
104+
console.error('Full error object:', error);
115105

116-
// Log additional error details for debugging
106+
// Check for specific error types
117107
if (error instanceof Error) {
108+
if (error.message.includes('reCAPTCHA')) {
109+
setSnackbar({
110+
isOpen: true,
111+
message: 'reCAPTCHA is still enabled. Please disable it in EmailJS settings.',
112+
type: 'error',
113+
});
114+
} else if (error.message.includes('400')) {
115+
setSnackbar({
116+
isOpen: true,
117+
message: 'Email service configuration issue. Please check EmailJS settings.',
118+
type: 'error',
119+
});
120+
} else {
121+
setSnackbar({
122+
isOpen: true,
123+
message: 'Network error. Please check your connection and try again.',
124+
type: 'error',
125+
});
126+
}
127+
118128
console.error('Error details:', {
119129
message: error.message,
120130
stack: error.stack
121131
});
132+
} else {
133+
setSnackbar({
134+
isOpen: true,
135+
message: 'Unknown error occurred. Please try again.',
136+
type: 'error',
137+
});
122138
}
123139
} finally {
124140
setIsSubmitting(false);

0 commit comments

Comments
 (0)