title: file attachment issue to email?
body: <p>My file is attached and sent with no error, but the attachment in my Inbox folder shows as follows:</p>
  
  <blockquote>
    <p>// this is included in the email subject and body, so not correct
            file attach boundary="==Multipart_Boundary_xb46dc57fb3a58f8a859f39992cfd954ex"
        This is a multi-part message in MIME format.
        // this is included in the email subject and body, so not correct
        --==Multipart_Boundary_xb46dc57fb3a58f8a859f39992cfd954ex
        Content-Type: text/plain; charset="iso-8859-1"
        Content-Transfer-Encoding: 7bit
         // this is included in the email subject and body, so not correct
        test message</p>
  
  <pre><code>--==Multipart_Boundary_xb46dc57fb3a58f8a859f39992cfd954ex
  Content-Type: image/jpeg;
  name="23.jpg"
  Content-Transfer-Encoding: base64
  
  /9j/4AAQSkZJRgABAQEAYABgAAD/4QC8RXhpZgAASUkqAF4AAAAEABoBBQABAAAAPgAAABsBBQAB
  AAAARgAAACgBAwABAAAAAgAAADEBAgAQAAAATgAAAAAAAABgAAAAAQAAAGAAAAABAAAAUGFpbnQu
  TkVUIHYzLjA4AAUAGgEFAAEAAAA+AAAAGwEFAAEAAABGAAAAKAEDAAEAAAACAAAAMQECABAAAAB
  </code></pre>
  </blockquote>
  
  <p>My sendemail.php code is:</p>
  
  <pre><code>&lt;?php
  
  $headers= "MIME-Version: 1.0";
  $headers= "Content-type: text/plain; charset=iso-8859-1";
  $headers= "From: $_POST[name] &lt;$_POST[email]&gt;";
  $headers= $_POST['name'];
  $subject = $_POST['subject'];
  $message = $_POST['message'];
  
  /* GET File Variables */ 
              $tmpName = $_FILES['attachment']['tmp_name']; 
              $fileType = $_FILES['attachment']['type']; 
              $fileName = $_FILES['attachment']['name']; 
  
              if (file_exists($tmpName)) { 
                /* Reading file ('rb' = read binary)  */
  
                $file = fopen($tmpName,'rb'); 
                $data = fread($file,filesize($tmpName)); 
                fclose($file); 
  
                /* a boundary string */
                $randomVal = md5(time()); 
                $mimeBoundary = "==Multipart_Boundary_x{$randomVal}x"; 
  
                /* Header for File Attachment */
                $headers = "\nMIME-Version: 1.0\n"; 
                $headers = "Content-Type: multipart/mixed;\n" ;
                $headers = " boundary=\"{$mimeBoundary}\""; 
  
                /* Multipart Boundary above message */
                $message = "This is a multi-part message in MIME format.\n\n" . 
                "--{$mimeBoundary}\n" . 
                "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . 
                "Content-Transfer-Encoding: 7bit\n\n" . 
                $message . "\n\n"; 
  
                /* Encoding file data */
                $data = chunk_split(base64_encode($data)); 
  
                /* Adding attchment-file to message*/
                $message .= "--{$mimeBoundary}\n" . 
                "Content-Type: {$fileType};\n" . 
                " name=\"{$fileName}\"\n" . 
                "Content-Transfer-Encoding: base64\n\n" . 
                $data . "\n\n" . 
                "--{$mimeBoundary}--\n"; 
  
              } 
  
              $to_user = "nur_Selam@yahoo.com";    
  
              $flgchk = mail($to_user, $subject, $message, $headers);     
  
              //require_once ('./includes/functions_mail.php');
  
                  if ($flgchk) {
  
                  echo "&lt;META HTTP-EQUIV=\"refresh\" CONTENT=\"2;url=forwardtoother.php?page=sender.html\"&gt;";
                  echo "Done, &lt;br&gt;";
                  echo "Redirecting you to your &lt;a href=\"?page=sender.html\"&gt;Inbox&lt;/a&gt;";
                  }
                  else
                  {
                       echo "&lt;META HTTP-EQUIV=\"refresh\" CONTENT=\"2;url=forwardtoother.php?page=sender.html\"&gt;";
                  echo "Failed to send email, &lt;br&gt;";
                  echo "Redirecting you to your &lt;a href=\"?page=sender.html\"&gt;Inbox&lt;/a&gt;";
                  }
              ?&gt;
  </code></pre>