diff --git a/backend/config.php b/backend/config.php deleted file mode 100644 index 2d303c9..0000000 --- a/backend/config.php +++ /dev/null @@ -1,10 +0,0 @@ - 'dev@andre-kempf.com', - 'from_email' => 'noreply@andre-kempf.com', - 'app_name' => 'Portfolio Contact', -]; \ No newline at end of file diff --git a/backend/sendMail.php b/backend/sendMail.php deleted file mode 100644 index 7d46e47..0000000 --- a/backend/sendMail.php +++ /dev/null @@ -1,79 +0,0 @@ -honeypot ?? $params->website_hp ?? $params->website ?? ''; - if (!empty($honeypot)) { - // Silently discard bot submission with 200 OK - http_response_code(200); - echo json_encode(["status" => "success"]); - exit; - } - - // Sanitize & validate incoming fields - $email = filter_var($params->email ?? '', FILTER_VALIDATE_EMAIL); - $name = htmlspecialchars(trim($params->name ?? 'Anonymous'), ENT_QUOTES, 'UTF-8'); - $text = htmlspecialchars(trim($params->message ?? ''), ENT_QUOTES, 'UTF-8'); - - if (!$email || empty($text)) { - http_response_code(400); - echo json_encode(["status" => "error", "message" => "Invalid input data"]); - exit; - } - - // Render HTML email template - $rawMessage = $params->message ?? ''; - $emailBody = renderEmailTemplate($name, $email, $text, $rawMessage); - $subject = "{$config['app_name']}: $name"; - - // Construct standard MIME headers - $headers = [ - 'MIME-Version: 1.0', - 'Content-type: text/html; charset=utf-8', - "From: {$config['from_email']}", - "Reply-To: $email" - ]; - - // Send email via PHP native mailer - $success = mail($config['recipient_email'], $subject, $emailBody, implode("\r\n", $headers)); - - if ($success) { - http_response_code(200); - echo json_encode(["status" => "success"]); - } else { - http_response_code(500); - echo json_encode(["status" => "error", "message" => "Failed to send email"]); - } - break; - - // 3. Reject Unsupported HTTP Methods - default: - header("Allow: POST, OPTIONS", true, 405); - http_response_code(405); - echo json_encode(["status" => "error", "message" => "Method Not Allowed"]); - exit; -} \ No newline at end of file diff --git a/backend/templates/emailTemplate.php b/backend/templates/emailTemplate.php deleted file mode 100644 index c91cc5b..0000000 --- a/backend/templates/emailTemplate.php +++ /dev/null @@ -1,53 +0,0 @@ - -
- - -
- // Portfolio Contact Message -

New message from {$safeName}

-
- - -
-
- From: {$safeName} ({$safeEmail}) -
-
{$formattedText}
-
- - -
- - ➜ Quick Reply - -
- -
- - "; -} \ No newline at end of file diff --git a/src/components/Contact.tsx b/src/components/Contact.tsx index ebef5e1..d47f863 100644 --- a/src/components/Contact.tsx +++ b/src/components/Contact.tsx @@ -3,7 +3,7 @@ import { useState } from "react"; /** - * Contact section with interactive form, bot anti-spam protection, and direct email info + * Contact section with interactive form, bot anti-spam protection, and Formspree integration */ export default function Contact() { // Form input states @@ -20,7 +20,7 @@ export default function Contact() { // Bot detection timestamp (form interaction speed check) const [formLoadTime] = useState(Date.now()); - // Handles contact form submission with bot verification & PHP backend dispatch + // Handles contact form submission with bot verification & Formspree dispatch const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); @@ -41,16 +41,21 @@ export default function Contact() { setError(false); try { - const response = await fetch( - "https://andre-kempf.com/backend/sendMail.php", - { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ name, email, message, honeypot }), + // Direct POST request to Formspree + const response = await fetch(`https://formspree.io/f/mojgbbzp`, { + method: "POST", + headers: { + "Content-Type": "application/json", + Accept: "application/json", }, - ); + body: JSON.stringify({ + name, + email, + message, + _replyto: email, + _subject: `Portfolio Contact: ${name}`, + }), + }); if (response.ok) { setSubmitted(true); @@ -177,6 +182,7 @@ export default function Contact() { setName(e.target.value)} @@ -193,6 +199,7 @@ export default function Contact() { setEmail(e.target.value)} @@ -208,6 +215,7 @@ export default function Contact() {