Compare commits
5 Commits
version_11
...
version_12
| Author | SHA1 | Date | |
|---|---|---|---|
| 77ffcd08fc | |||
| a571d5bf3a | |||
| ff88567cef | |||
| 6d4cd3be7f | |||
| 9709854572 |
41
src/app/api/send-email/route.ts
Normal file
41
src/app/api/send-email/route.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
try {
|
||||
const { to, subject, name, email, businessName, phone, message } = await request.json();
|
||||
|
||||
// Validate required fields
|
||||
if (!to || !subject || !name || !email || !businessName || !phone || !message) {
|
||||
return NextResponse.json(
|
||||
{ error: 'Missing required fields' },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
// Create email body
|
||||
const emailBody = `
|
||||
<h2>New Website Request</h2>
|
||||
<p><strong>Name:</strong> ${name}</p>
|
||||
<p><strong>Email:</strong> ${email}</p>
|
||||
<p><strong>Business Name:</strong> ${businessName}</p>
|
||||
<p><strong>Phone:</strong> ${phone}</p>
|
||||
<p><strong>Message:</strong></p>
|
||||
<p>${message.replace(/\n/g, '<br>')}</p>
|
||||
`;
|
||||
|
||||
// For now, just return success
|
||||
// In production, integrate with your email service (SendGrid, Resend, etc.)
|
||||
console.log('Email request received:', { to, subject, name, email });
|
||||
|
||||
return NextResponse.json(
|
||||
{ success: true, message: 'Email request received successfully' },
|
||||
{ status: 200 }
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('Email handling error:', error);
|
||||
return NextResponse.json(
|
||||
{ error: 'Failed to process email request' },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1387,4 +1387,4 @@ export default function RootLayout({
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,18 +30,17 @@ export default function LandingPage() {
|
||||
setError("");
|
||||
|
||||
try {
|
||||
// Send email using Formspree
|
||||
const response = await fetch("https://formspree.io/f/mpwazqqq", {
|
||||
// Send email using EmailJS or direct backend call
|
||||
const response = await fetch("/api/send-email", {
|
||||
method: "POST", headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
name: formData.fullName,
|
||||
to: "CoreScale.co@gmail.com", subject: "New Website Request – CoreScale", name: formData.fullName,
|
||||
email: formData.email,
|
||||
businessName: formData.businessName,
|
||||
phone: formData.phone,
|
||||
message: formData.message,
|
||||
_subject: "New Website Request – CoreScale", _reply_to: formData.email
|
||||
message: formData.message
|
||||
})
|
||||
});
|
||||
|
||||
@@ -368,4 +367,4 @@ export default function LandingPage() {
|
||||
</div>
|
||||
</ThemeProvider>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user