New Contact Form Submission
| Name | " . $fullName . " |
| Email | " . $email . " |
| Farm Type | " . $farmLabel . " |
| Message | " . nl2br($message) . " |
";
$bodyText = "Name: {$fullName}\nEmail: {$email}\nFarm Type: {$farmLabel}\n\nMessage:\n{$message}";
// Send via PHPMailer
$mail = new PHPMailer(true);
try {
$mail->isSMTP();
$mail->Host = MAIL_HOST;
$mail->SMTPAuth = true;
$mail->Username = MAIL_USERNAME;
$mail->Password = MAIL_PASSWORD;
$mail->SMTPSecure = MAIL_ENCRYPTION === 'ssl' ? PHPMailer::ENCRYPTION_SMTPS : PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port = MAIL_PORT;
$mail->setFrom(MAIL_FROM, MAIL_FROM_NAME);
$mail->addAddress(MAIL_TO);
$mail->addReplyTo($email, $fullName);
$mail->isHTML(true);
$mail->Subject = 'Contact Form: ' . $fullName . ' (' . $farmLabel . ')';
$mail->Body = $bodyHtml;
$mail->AltBody = $bodyText;
$mail->send();
$_SESSION['contact_success'] = 'Thank you, ' . $firstName . '. We\'ll be in touch soon.';
} catch (Exception $e) {
error_log('Contact form mailer error: ' . $mail->ErrorInfo);
$_SESSION['contact_error'] = 'Sorry, we couldn\'t send your message. Please try again later.';
}
header('Location: /#contact');
exit;