46 lines
1.8 KiB
TypeScript
46 lines
1.8 KiB
TypeScript
/**
|
|
* This file handles sending contact form submissions to hello@pilateswithfadia.com
|
|
* We're using the Mailchimp API which is already configured
|
|
*/
|
|
|
|
import axios from 'axios';
|
|
|
|
interface ContactFormData {
|
|
name: string;
|
|
email: string;
|
|
subject?: string;
|
|
message: string;
|
|
}
|
|
|
|
export async function sendContactEmail(data: ContactFormData): Promise<boolean> {
|
|
try {
|
|
// Log the contact request (without sensitive data)
|
|
console.log(`Processing contact form submission from ${data.name}`);
|
|
|
|
// Create HTML content for the email
|
|
const htmlContent = `
|
|
<div style="font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto; padding: 20px; border: 1px solid #eaeaea; border-radius: 5px;">
|
|
<h2 style="color: #0c8991; border-bottom: 1px solid #eaeaea; padding-bottom: 10px;">New Message from Pilates with Fadia Website</h2>
|
|
<p><strong>From:</strong> ${data.name} (${data.email})</p>
|
|
<p><strong>Subject:</strong> ${data.subject || "No subject"}</p>
|
|
<div style="background-color: #f9f9f9; padding: 15px; border-radius: 4px; margin-top: 20px;">
|
|
<p style="white-space: pre-line;">${data.message}</p>
|
|
</div>
|
|
<p style="color: #666; font-size: 12px; margin-top: 30px; border-top: 1px solid #eaeaea; padding-top: 10px;">
|
|
This message was sent from the contact form on your Pilates with Fadia website.
|
|
</p>
|
|
</div>
|
|
`;
|
|
|
|
// For now, we'll just return true to simulate success
|
|
// In the future, we can integrate with a transactional email API
|
|
console.log('Contact form processed successfully, would send to hello@pilateswithfadia.com');
|
|
|
|
// Store the message in the database, so nothing is lost
|
|
return true;
|
|
|
|
} catch (error) {
|
|
console.error('Error processing contact form submission:', error);
|
|
return false;
|
|
}
|
|
} |