" . htmlspecialchars($error) . "";
}
echo "
The following errors occurred:
";
exit;
}
// 1. Email to Company Admin
$to = "contact@eddysconstruction.com";
$admin_body = "You have received a new contact request:\n\n";
$admin_body .= "Name: " . $name . "\n";
$admin_body .= "Email: " . $email . "\n";
$admin_body .= "Phone: " . $phone . "\n";
$admin_body .= "Address / ZIP Code: " . $address_zip . "\n";
$admin_body .= "Phone Call Allowed: " . $phone_allowed . "\n";
$admin_body .= "Best Time for Contact: " . $best_time . "\n";
$admin_body .= "Marketing Consent: " . $marketing_optin . "\n";
$admin_body .= "Subject: " . $subject . "\n\n";
$admin_body .= "Message:\n" . $message . "\n";
$admin_headers = array();
$admin_headers[] = "MIME-Version: 1.0";
$admin_headers[] = "Content-Type: text/plain; charset=UTF-8";
$admin_headers[] = "From: Eddy's Construction ";
$admin_headers[] = "Reply-To: " . $name . " <" . $email . ">";
$admin_headers[] = "X-Mailer: PHP/" . phpversion();
$sent = @mail($to, "New Estimate Request: " . $subject, $admin_body, implode("\r\n", $admin_headers));
// 2. Auto-reply Email to Customer
if ($sent) {
$client_subject = "We received your request - Eddy's Construction & Masonry";
$client_body = "Hello " . htmlspecialchars($name) . ",\n\n";
$client_body .= "Thank you for reaching out to Eddy's Construction & Masonry LLC.\n\n";
$client_body .= "We have received your request for an estimate/information regarding: \"" . htmlspecialchars($subject) . "\". Our team is currently reviewing your message and will get back to you shortly.\n\n";
$client_body .= "IMPORTANT: To ensure our future communications reach your inbox, please reply directly to this email or add contact@eddysconstruction.com to your contacts list.\n\n";
$client_body .= "If you did not see this message in your primary inbox, please check your Spam or Junk Mail folder.\n\n";
$client_body .= "Best regards,\n";
$client_body .= "Eddy's Construction & Masonry Team\n";
$client_body .= "(508) 782-2159 | https://eddysconstruction.com\n\n";
$client_body .= "--- \n";
$client_body .= "If you ever wish to unsubscribe from our informational updates, please reply to this email with 'UNSUBSCRIBE' in the subject line or visit https://eddysconstruction.com/privacy.html.";
$client_headers = array();
$client_headers[] = "MIME-Version: 1.0";
$client_headers[] = "Content-Type: text/plain; charset=UTF-8";
$client_headers[] = "From: Eddy's Construction ";
$client_headers[] = "Reply-To: contact@eddysconstruction.com";
@mail($email, $client_subject, $client_body, implode("\r\n", $client_headers));
// Indicativo para o JS redirecionar para a página thankyou.html
echo "REDIRECT:thankyou.html";
} else {
echo "Server error: Unable to send email right now. Please call us directly at (508) 782-2159.
";
}