I’m trying to get a copy of an existing PHP site up and running on my Windows 2008 Server. I’ve installed PHP using the Microsoft Web Platform Installer (v4.5). The installation seemed to go fine, and I’ve managed to display the phpinfo page.
There’s a contact form on the site which captures user details and sends an email - the code of the php which is executed on form submission is below. This functionality works on the live site, but when I submit the form on my Windows server it simply echos the content of the .php file (i.e. the code below) to the page.
I’ve configured the SMTP server in php.ini to use localhost on port 25, and have successfully sent an outbound email using the local SMTP server.
Can anyone suggest why this is happening?
[php]
<? $strContents = " This is an email from the xxxxx website\n \nSender: \t ".$_POST['firstName']." \n
Email: \t ".$_POST['_sendersemail']." \n
Telephone: \t ".$_POST['phoneNumber']." \n
Company: \t ".$_POST['enquiry']." \n
"; if (!sendMail(array('subject' => 'Contact Form', 'contents' => $strContents, 'recipients' => array( array('emailAddress' => '[email protected]') )))) { header('Location: ' . $_POST['missing_fields_redirect']); } function sendMail($arrMail) { if (!array_key_exists('contents', $arrMail)) {return false;} else {$strContents = $arrMail['contents'];} if (!array_key_exists('recipients', $arrMail)) {return false;} $headers = "From: xxxxxx contact form \n"; $headers .= "Return-Path: \n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Type: text/html; charset=UTF-8\n"; foreach ($arrMail['recipients'] as $arrRecipient) { if (!mail($arrRecipient['emailAddress'],$arrMail['subject'],$strContents, $headers)) {return false;} } return true; } header('Location: ' . $_POST['redirect']); ?>
[/php]