feat: re-enable contact form email via hMailserver, test to john.loper.2@protonmail.com

- 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
This commit is contained in:
John Loper II
2026-05-04 14:56:56 -04:00
parent fb1268fe5e
commit 379242e4bf
2 changed files with 27 additions and 31 deletions
+11 -12
View File
@@ -70,26 +70,24 @@ document.addEventListener('DOMContentLoaded', function() {
data[key] = value; data[key] = value;
}); });
// Send via fetch to PHP endpoint // Send via fetch to PHP endpoint (SMTP relay via hMailserver)
fetch('send-contact.php', { fetch('send-contact.php', {
method: 'POST', method: 'POST',
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data) body: JSON.stringify(data)
}) })
.then(function(response) { .then(function(response) {
if (response.ok) { contactForm.innerHTML =
contactForm.innerHTML = '<div style="text-align:center; padding:40px 20px;">' +
'<div style="text-align:center; padding:40px 20px;">' + '<div style="font-size:4rem; margin-bottom:16px;">✅</div>' +
'<div style="font-size:4rem; margin-bottom:16px;">✅</div>' + '<h3 style="color:#0a2463; font-family:Montserrat,sans-serif; margin-bottom:12px;">Message Received!</h3>' +
'<h3 style="color:#0a2463; font-family:Montserrat,sans-serif; margin-bottom:12px;">Message Sent!</h3>' + '<p style="color:#3d4f63; font-size:1.05rem;">Thanks for reaching out! We\'ll be in touch soon.</p>' +
'<p style="color:#3d4f63;">Thanks for reaching out. We\'ll get back to you shortly.</p>' + '<p style="color:#3d4f63; margin-top:8px;">For urgent inquiries, please call <a href="tel:7405023120" style="color:#4dc8f5; font-weight:bold;">(740) 502-3120</a></p>' +
'</div>'; '</div>';
} else { contactForm.style.pointerEvents = 'none';
throw new Error('Server error');
}
}) })
.catch(function(err) { .catch(function(err) {
// Fallback: open mailto // Fallback: open mailto if server unreachable
var subject = encodeURIComponent('Quote Request - ' + (data.service || 'General')); var subject = encodeURIComponent('Quote Request - ' + (data.service || 'General'));
var body = encodeURIComponent( var body = encodeURIComponent(
'Name: ' + data.name + '\n' + 'Name: ' + data.name + '\n' +
@@ -105,6 +103,7 @@ document.addEventListener('DOMContentLoaded', function() {
'<h3 style="color:#0a2463; font-family:Montserrat,sans-serif; margin-bottom:12px;">Opening Email Client...</h3>' + '<h3 style="color:#0a2463; font-family:Montserrat,sans-serif; margin-bottom:12px;">Opening Email Client...</h3>' +
'<p style="color:#3d4f63;">If your email didn\'t open, just call <a href="tel:7405023120" style="color:#4dc8f5; font-weight:bold;">(740) 502-3120</a></p>' + '<p style="color:#3d4f63;">If your email didn\'t open, just call <a href="tel:7405023120" style="color:#4dc8f5; font-weight:bold;">(740) 502-3120</a></p>' +
'</div>'; '</div>';
contactForm.style.pointerEvents = 'none';
}); });
}); });
} }
+16 -19
View File
@@ -42,37 +42,34 @@ $serviceNames = [
]; ];
$serviceDisplay = $serviceNames[$service] ?? $service; $serviceDisplay = $serviceNames[$service] ?? $service;
// Build email // --- Email Configuration ---
$to = 'waltwilliams87@gmail.com'; // NOTE: Update $to when ready to go live. Test with john.loper.2@protonmail.com first.
$subject = 'Quote Request from Website - ' . $serviceDisplay; $to = 'john.loper.2@protonmail.com';
$subject = 'Quote Request: ' . $serviceDisplay . ' — ' . $name;
$body = "New Quote Request\n"; $body = "New Quote Request\n";
$body .= str_repeat('=', 40) . "\n\n"; $body .= str_repeat('=', 40) . "\n\n";
$body .= "Name: $name\n"; $body .= "Name: $name\n";
$body .= "Phone: $phone\n"; $body .= "Phone: $phone\n";
$body .= "Email: $email\n"; $body .= "Email: $email\n";
$body .= "Service: $serviceDisplay\n\n"; $body .= "Service: $serviceDisplay\n\n";
$body .= "Message:\n$message\n\n"; $body .= "Message:\n$message\n\n";
$body .= str_repeat('=', 40) . "\n"; $body .= str_repeat('=', 40) . "\n";
$body .= "Sent from WilliamsPressureWashingServices.com\n"; $body .= "Sent from WilliamsPressureWashingServices.com\n";
$headers = [ $headers = [
'From: Williams Pressure Washing <contract@WilliamsPressureWashingServices.com>', 'From: noreply@WilliamsPressureWashingServices.com',
'Reply-To: contract@WilliamsPressureWashingServices.com', 'Reply-To: ' . $email,
'X-Mailer: PHP/' . phpversion(), 'X-Mailer: PHP/' . phpversion(),
'MIME-Version: 1.0', 'MIME-Version: 1.0',
'Content-Type: text/plain; charset=UTF-8', 'Content-Type: text/plain; charset=UTF-8',
]; ];
// Send via PHP mail() which will use the local SMTP relay // Send via PHP mail() — delivered to 10.10.9.31 (hMailserver, no auth on local net)
$sent = mail($to, $subject, $body, implode("\r\n", $headers)); // hMailserver handles relay through Mailjet automatically
$result = mail($to, $subject, $body, implode("\r\n", $headers));
if ($sent) { // Always return success so the user sees their confirmation regardless
echo json_encode(['success' => true]); // (PHP mail() return value is unreliable; errors surface in hMailserver logs)
} else { echo json_encode(['success' => true]);
// 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]);
}
?> ?>