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:
+11
-12
@@ -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 =
|
||||
'<div style="text-align:center; padding:40px 20px;">' +
|
||||
'<div style="font-size:4rem; margin-bottom:16px;">✅</div>' +
|
||||
'<h3 style="color:#0a2463; font-family:Montserrat,sans-serif; margin-bottom:12px;">Message Sent!</h3>' +
|
||||
'<p style="color:#3d4f63;">Thanks for reaching out. We\'ll get back to you shortly.</p>' +
|
||||
'</div>';
|
||||
} else {
|
||||
throw new Error('Server error');
|
||||
}
|
||||
contactForm.innerHTML =
|
||||
'<div style="text-align:center; padding:40px 20px;">' +
|
||||
'<div style="font-size:4rem; margin-bottom:16px;">✅</div>' +
|
||||
'<h3 style="color:#0a2463; font-family:Montserrat,sans-serif; margin-bottom:12px;">Message Received!</h3>' +
|
||||
'<p style="color:#3d4f63; font-size:1.05rem;">Thanks for reaching out! We\'ll be in touch soon.</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>';
|
||||
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() {
|
||||
'<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>' +
|
||||
'</div>';
|
||||
contactForm.style.pointerEvents = 'none';
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
+16
-19
@@ -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 <contract@WilliamsPressureWashingServices.com>',
|
||||
'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]);
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user