title: php mail() function to send mail with an attachment
body: <p>I have created two scripts for this HTML and a corresponding PHP.</p>
  
  <p>HTML markup:</p>
  
  <pre><code>&lt;html&gt;
    &lt;body&gt;
      &lt;form action="http://senindiaonline.in/admar/non-series-numbers-db.php" method="post" target="_blank" name="non_series_numbers_db" enctype="multipart/form-data"&gt;
        &lt;label for="emp-id"&gt;Employee ID: &lt;/label&gt;
        &lt;input type="text" name="emp-id" id="emp-id" maxlength="15" style='text-transform:uppercase'/&gt;
        &lt;br/&gt;
        &lt;label for="no-csv"&gt;If you have a mobile number database in CSV file format upload that here: &lt;/label&gt;
        &lt;input name="no-csv" id="no-csv" type="file" accept=".csv"/&gt;
        &lt;br/&gt;
        &lt;label for="no-xls"&gt;If you have a mobile number database in XLS (excel) file format upload that here: &lt;/label&gt;
        &lt;input name="no-xls" id="no-xls" type="file" accept=".xls"/&gt;
        &lt;br/&gt;
        &lt;label for="no-xlsx"&gt;If you have a mobile number database in XLSX (excel) file format upload that here: &lt;/label&gt;
        &lt;input name="no-xlsx" id="no-xlsx" type="file" accept=".xlsx"/&gt;
        &lt;br/&gt;
        &lt;input name="send" value="Send" type="submit" id="send"/&gt;
      &lt;/form&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>PHP script:</p>
  
  <pre><code>&lt;?php
  error_reporting(0);
  $email_to = 'senindiagroup@gmail.com';
  $email_subject = "Non-Seriesed Mobile Number Database from Ad&amp;Marketing Employee Panel of Sen India Online inc.";    
  $emp_id = $_POST['emp-id'];
  $sub="Employee ID: $emp_id";
  $bound_text = "jimmyPI23";
  $bound = "--" .$bound_text. "\r\n";
  $bound_last = "--" .$bound_text. "--\r\n";
  $email_message .= "If you can see this MIME than your  client doesn't accept MIME types! \r\n" .$bound;
  $email_message .= "Content-Type: text/html; Charset=\"iso-8859-1\"\r\n" ."Content-Transfer-Encoding: 7bit\r\n\r\n" ."$sub\r\n" .$bound;
  
  //getting temporary file location with name
  $a=file_get_contents($_FILES['no-csv']['tmp_name']);
  $b=file_get_contents($_FILES['no-xls']['tmp_name']);
  $c=file_get_contents($_FILES['no-xlsx']['tmp_name']);
  
  //getting original name of the file you uploaded
  $name=$_FILES["no-csv"]["name"];
  $name1=$_FILES["no-xls"]["name"];
  $name2=$_FILES["no-xlsx"]["name"];
  
  $email_message .= "Content-Type: {\"application/octet-stream\"}; \n" . "name=\"$name\ "\n" . "Content-Transfer-Encoding: base64\r\n" ."Content-Disposition: attachment; \n" . " filename=\"$name\ "\n"."\r\n" .chunk_split(base64_encode($a)).$bound;
  
  mail($email_to, $email_subject, $email_message, $headers);
  ?&gt;
  </code></pre>
  
  <p>The error is:</p>
  
  <blockquote>
    <p>syntax error showing on line 31, attach file with mail command. </p>
  </blockquote>
  
  <p>And the mail is not send. I solve this error with DreamWeaver suggestion. Then the mail is send, but the attachment is not included in the mail.</p>