I've been reading into php mail injection and possible security risks. I've decided to control most of this via a function and simply pass in the from email and contact message.
just wondered how secure this was and does it prevent any sort of injection?
//contact form
function sendContactForm($contactEmail, $contactMessage) {
$to = "mysite@mysite.com";
$from = "mysite@mysite.com";
$replyTo = filter_var($contactEmail, FILTER_VALIDATE_EMAIL);
$subject = "Contact Form Email";
$message = $contactMessage;
$headers = "From: " . $from . "\r\n";
$headers = "Reply-To:" . $replyTo . "\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($to, $subject, $message, $headers);
}