New Contact Form Submission";
$html_content .= "
Name: " . htmlspecialchars($name) . "
";
$html_content .= "Email: " . htmlspecialchars($email) . "
";
$html_content .= "Message:
" . nl2br(htmlspecialchars($message)) . "
";
$text_content = "New Contact Form Submission\n";
$text_content .= "Name: " . $name . "\n";
$text_content .= "Email: " . $email . "\n";
$text_content .= "Message:\n" . $message . "\n";
$options = [
'reply_to' => $email,
'from_name' => $name
];
$result = MailService::sendMail($to, $subject, $html_content, $text_content, $options);
if (!empty($result['success'])) {
header("Location: index.php?status=success#contact");
exit;
} else {
error_log("MailService Error: " . ($result['error'] ?? 'Unknown error'));
header("Location: index.php?status=error&msg=Could+not+send+message#contact");
exit;
}
} else {
header("Location: index.php");
exit;
}