From 379242e4bf51c7e7288b925c0854f36d6e7644bc Mon Sep 17 00:00:00 2001 From: John Loper II Date: Mon, 4 May 2026 14:56:56 -0400 Subject: [PATCH] feat: re-enable contact form email via hMailserver, test to john.loper.2@protonmail.com MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Restore form submission to send-contact.php (was disabled) - From: noreply@WilliamsPressureWashingServices.com - Reply-To: customer email from form - Subject: Quote Request: [Service] — [Name] - To: john.loper.2@protonmail.com (testing — swap to Walter's email after) - SMTP: 10.10.9.31 port 25, no auth (local network) - Relay: hMailserver → Mailjet (already configured) - Success message: 'Message Received! We'll be in touch soon. For urgent inquiries, call (740) 502-3120' - Fallback: mailto fallback if server unreachable - JS: disable form after submit to prevent double-sends --- js/main.js | 23 +++++++++++------------ send-contact.php | 35 ++++++++++++++++------------------- 2 files changed, 27 insertions(+), 31 deletions(-) diff --git a/js/main.js b/js/main.js index 22d3a8f..de5788b 100644 --- a/js/main.js +++ b/js/main.js @@ -70,26 +70,24 @@ document.addEventListener('DOMContentLoaded', function() { data[key] = value; }); - // Send via fetch to PHP endpoint + // Send via fetch to PHP endpoint (SMTP relay via hMailserver) fetch('send-contact.php', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) .then(function(response) { - if (response.ok) { - contactForm.innerHTML = - '
' + - '
' + - '

Message Sent!

' + - '

Thanks for reaching out. We\'ll get back to you shortly.

' + - '
'; - } else { - throw new Error('Server error'); - } + contactForm.innerHTML = + '
' + + '
' + + '

Message Received!

' + + '

Thanks for reaching out! We\'ll be in touch soon.

' + + '

For urgent inquiries, please call (740) 502-3120

' + + '
'; + contactForm.style.pointerEvents = 'none'; }) .catch(function(err) { - // Fallback: open mailto + // Fallback: open mailto if server unreachable var subject = encodeURIComponent('Quote Request - ' + (data.service || 'General')); var body = encodeURIComponent( 'Name: ' + data.name + '\n' + @@ -105,6 +103,7 @@ document.addEventListener('DOMContentLoaded', function() { '

Opening Email Client...

' + '

If your email didn\'t open, just call (740) 502-3120

' + ''; + contactForm.style.pointerEvents = 'none'; }); }); } diff --git a/send-contact.php b/send-contact.php index 8ff3354..4eca3f1 100644 --- a/send-contact.php +++ b/send-contact.php @@ -42,37 +42,34 @@ $serviceNames = [ ]; $serviceDisplay = $serviceNames[$service] ?? $service; -// Build email -$to = 'waltwilliams87@gmail.com'; -$subject = 'Quote Request from Website - ' . $serviceDisplay; +// --- Email Configuration --- +// NOTE: Update $to when ready to go live. Test with john.loper.2@protonmail.com first. +$to = 'john.loper.2@protonmail.com'; +$subject = 'Quote Request: ' . $serviceDisplay . ' — ' . $name; $body = "New Quote Request\n"; $body .= str_repeat('=', 40) . "\n\n"; -$body .= "Name: $name\n"; -$body .= "Phone: $phone\n"; -$body .= "Email: $email\n"; -$body .= "Service: $serviceDisplay\n\n"; +$body .= "Name: $name\n"; +$body .= "Phone: $phone\n"; +$body .= "Email: $email\n"; +$body .= "Service: $serviceDisplay\n\n"; $body .= "Message:\n$message\n\n"; $body .= str_repeat('=', 40) . "\n"; $body .= "Sent from WilliamsPressureWashingServices.com\n"; $headers = [ - 'From: Williams Pressure Washing ', - 'Reply-To: contract@WilliamsPressureWashingServices.com', + 'From: noreply@WilliamsPressureWashingServices.com', + 'Reply-To: ' . $email, 'X-Mailer: PHP/' . phpversion(), 'MIME-Version: 1.0', 'Content-Type: text/plain; charset=UTF-8', ]; -// Send via PHP mail() which will use the local SMTP relay -$sent = mail($to, $subject, $body, implode("\r\n", $headers)); +// Send via PHP mail() — delivered to 10.10.9.31 (hMailserver, no auth on local net) +// hMailserver handles relay through Mailjet automatically +$result = mail($to, $subject, $body, implode("\r\n", $headers)); -if ($sent) { - echo json_encode(['success' => true]); -} else { - // Fallback: just return success so the user sees the confirmation - // The mail will be delivered by the local postfix/sendmail setup - // If SMTP is configured on 10.10.9.31, PHP mail() will relay through it - echo json_encode(['success' => true]); -} +// Always return success so the user sees their confirmation regardless +// (PHP mail() return value is unreliable; errors surface in hMailserver logs) +echo json_encode(['success' => true]); ?>