PHP form script works on my server, but not on another server
<p>I've been writing a website and added some forms that all worked perfectly on my own web space. Once uploaded to my clients server they return the error message that I wrote in the PHP. I'm assuming there isn't an error in the code as like I said it does work on mine.</p>

<p>Here is the code:</p>

<pre><code>&lt;?php

$websitename="Automating Trades"; 

$allowtypes=array("zip", "rar", "txt", "doc", "jpg", "png", "gif",
"odt", "xml");

$myemail="admin@email.com";

$priority="2"; 

$allowattach="1"; 

// 2048kb = 2MB,       1024kb = 1MB,     512kb = 1/2MB etc..
$max_file_size="1024";

 // 2048kb = 2MB,       1024kb = 1MB,     512kb = 1/2MB etc..
 $max_file_total="2048";

 $submitvalue=" Send "; 

 $defaultsubject="Heading"; 

 $use_subject_drop=false;

 $subjects=array("Department 1", "Department 2", "Department 3");

 $emails=array("dept_1@domain.com", "dept_2@domain.com",    
 "dept_3@domain.com");


 $thanksmessage=" Thank You for the message, we will get back to
 shortly.";


 // Function to get the extension of the uploaded file. function
 get_ext($key) {    $key=strtolower(substr(strrchr($key, "."), 1));
    $key=str_replace("jpeg", "jpg", $key);  return $key; }

 // Function used to attach files to the message function
 phattach($file, $name, $boundary) {        $fp=fopen($file, "r");
    $str=fread($fp, filesize($file));
    $str=chunk_split(base64_encode($str));  $message="--".$boundary."\n";
    $message.="Content-Type: application/octet-stream;
 name=\"".$name."\"\n";     $message.="Content-disposition: attachment;
 filename=\"".$name."\"\n";     $message.="Content-Transfer-Encoding:
 base64\n";     $message.="\n";     $message.="$str\n";     $message.="\n";

    return $message; }

 //Little bit of security from people forging headers. People are mean
 sometimes :( function clean_msg($key) {    $key=str_replace("\r", "",
 $key);     $key=str_replace("\n", "", $key);   $find=array(        "/bcc\:/i",
        "/Content\-Type\:/i",       "/Mime\-Type\:/i",      "/cc\:/i",      "/to\:/i"
    );   $key=preg_replace($find, "", $key);   return $key; }

 // Initilize some variables $error=""; $sent_mail=false;

 // When the form is submitted If($_POST['submit']==true) {
    extract($_POST, EXTR_SKIP);

        // Check the form for errors        If(trim($yourname)=="") { 
            $error.="You did not enter your name!&lt;br /    ";        }
                If(trim($youremail)=="") {              $error.="You did not enter your email!&lt;br /&gt;";      }
 Elseif(!preg_match("/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/",
 $youremail)) {             $error.="Invalid email address.&lt;br /&gt;";         }

        If(trim($emailsubject)=="") {           $emailsubject=$defaultsubject;      }

        If(trim($yourmessage)=="") {            $error.="You did not enter a
 message!&lt;br /&gt;";       }
                // Verify Attchment info        If($allowattach &gt; 0) {
                        // Get the total size of all uploaded files             If((array_sum($_FILES['attachment']['size'])) &gt;
 ($max_file_total*1024)) {

                $error.="The max size allowed for all your files is ".$max_file_total."kb&lt;br /&gt;";
                            } Else {

                //Loop through each of the files
                For($i=0; $i &lt;= $allowattach-1; $i++) {

                    If($_FILES['attachment']['name'][$i]) {

                        //Check if the file type uploaded is a valid file type. 
                        If(!in_array(get_ext($_FILES['attachment']['name'][$i]), $allowtypes)) {

                            $error.= "Invalid file type for your file: ".$_FILES['attachment']['name'][$i]."&lt;br /&gt;";

                        //Check the size of each file
                        } Elseif(($_FILES['attachment']['size'][$i]) &gt; ($max_file_size*1024)) {

                            $error.= "Your file: ".$_FILES['attachment']['name'][$i]." is to big.&lt;br /&gt;";

                        } // If in_array

                    } // If Files

                } // For
                            } // Else array_sum($_FILES['attachment']['size'])
                    } // If Allowattach

    If($error) {
            $display_message=$error;

    } Else {
                If($use_subject_drop AND is_array($subjects) AND is_array($emails)) {           $subject_count=count($subjects);
            $email_count=count($emails);
                        If($subject_count==$email_count) {

                $myemail=$emails[$emailsubject];
                $emailsubject=$subjects[$emailsubject];

            } // If $subject_count
                    } // If $use_subject_drop

        $boundary=md5(uniqid(time()));
                //Headers       $headers="Return-Path: &lt;".clean_msg($youremail)."&gt;\n";      $headers.="From:
 ".clean_msg($yourname)." &lt;".clean_msg($youremail)."&gt;\n";
        $headers.="X-Mailer: PHP/".phpversion()."\n";       $headers.="X-Sender:
 ".$_SERVER['REMOTE_ADDR']."\n";        $headers.="X-Priority:
 ".$priority."\n";          $headers.="MIME-Version: 1.0\n";
        $headers.="Content-Type: multipart/mixed;
 boundary=\"".$boundary."\"\n";         $headers.="This is a multi-part
 message in MIME format.\n";

        //Message       $message = "--".$boundary."\n";
        $message.="Content-Type: text/html; charset=\"iso-8859-1\"\n";
        $message.="Content-Transfer-Encoding: quoted-printable\n";
        $message.="\n";
        $message.=clean_msg(nl2br(strip_tags($yourmessage)));
        $message.="\n";

        //Add attachments to message        If($allowattach &gt; 0) {
                        For($i=0; $i &lt;= $allowattach-1; $i++) {

                If($_FILES['attachment']['tmp_name'][$i]) {

                    $message.=phattach($_FILES['attachment']['tmp_name'][$i], $_FILES['attachment']['name'][$i], $boundary);

                } //If $_FILES['attachment']['name'][$i]
                            } //For
                    } // If
                // End the message      $message.="--".$boundary."--\n";
                // Send the completed message       If(!mail($myemail, clean_msg($emailsubject), $message, $headers)) {
                        Exit("**An error has occured, please report this to the website administrator**.\n");
                    } Else {
                    $sent_mail=true;
                    }

    } // Else

 } // $_POST

 ?&gt;
</code></pre>

<p>Exit("<strong>An error has occured, please report this to the website administrator</strong>.\n");</p>

<p>This is the error message that returns.</p>

<p>Hope someone can help, Thanks.</p>
