title: PHP script returning false not sure why
body: <p>My script is not working, and I have no idea why. Any suggestions? </p>
  
  <pre><code>&lt;?php
      class email
      {
          function emailPlusAttachment($fromAddress,$toAddress,$mailSubject,$mailMessageHead,$mailMessageMain,$mailMessageSign,$filePath,$fileName)
          {
  
              $fileatt_name = $fileName;
              $fileatt = $filePath.$fileName;
              $fileatt_type = "application/octet-stream";
              $email_from = $fromAddress;
              $email_subject = $mailSubject;
  
              $email_message = $mailMessageHead. "&lt;br&gt;";
              $email_message .= $mailMessageMain. "&lt;br&gt;";
              $email_message .= $mailMessageSign;
  
              $email_to = $toAddress;
  
              $headers = "From: ".$email_from;
  
              $file = fopen($fileatt, 'rb');
              $data = fread($file, filesize($fileatt));
              fclose($file);
  
              $semi_rand = md5(time());
              $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
  
              $headers .= "\nMIME-Version: 1.0\n" .
              "Content-Type: multipart/mixed:\n" .
              " boundary=\"{$mime_boundary}\"";
  
              $email_message .= "This is a multi-part message in MIME format.\n\n" .
              "--{$mime_boundary}\n" .
              "Content-Type:text/html; charset=\"iso-8859-1\"\n" .
              "Content-Transfer-Encoding: 7bit\n\n" .
              $email_message .= "\n\n";
  
              $data = chunk_split(base64_encode($data));
  
              $email_message .= "--{$mime_boundary}\n" .
              "Content-Type: {$fileatt_type}; \n" .
              " name=\"{$fileatt_name}\"\n" .
              "Content-Transfer-Encoding: base64\n\n" .
              $data .= "\n\n" .
              "--{$mime_boundary}--\n";
  
              if (@mail($email_to, $email_subject, $email_message, $headers)) 
              {
                return true;
              }
          }
      }
  ?&gt;
  </code></pre>
  
  <p>with:
      
  
  <pre><code>    $from       =   'sender@tjaa.co.uk';
      $sendto     =   'recipient@hotmail.co.uk';
      $subject    =   'email with one attachment';
      $bodyHead   =   'Hello Drew';
      $bodyMain   =   'There is an attachment associated with this email.';
      $bodyEnd    =   'Thank you';
      $filePath   =   '';
      $fileName   =   'logo.png';
  
      if ($sendEmail-&gt;emailPlusAttachment($from,$sendto,$subject,$bodyHead,$bodyMain,$bodyEnd,$filePath,$fileName))
      {
  
          echo "email sent";
      }   
      else {echo "email not sent";}
  
  ?&gt;
  </code></pre>
  
  <p>It simply <code>echo</code>s "email not send", indicating return false... any pointers?</p>
  
  <p>What are the chances its a syntax error, or can anyone identify a bigger problem?</p>