hello

Creating excel sheet with dynamic data and send email with excel shett
attachment. Its runing fine on localhost but on server create excel
sheet and go mail whith attachment but my excelsheet is blank my data
is not write in excelsheet .whet is problem . pls hep me

here my code

 <?php

      $filename ="excelreport.xls";
      $contents = "testdata1 \t testdata2 \t testdata3 \t \n";
      header('Content-type: application/ms-excel');
      header('Content-Disposition: attachment; filename='.$filename);
      echo $contents;
  $header."\n".$data;


      $files =$filename;

          $to = "[email protected]";
      $from = "[email protected]";
      $subject ="Maill Attachment test";
      $message = "My message";
      $headers = "From: $from";
      $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}\"";
      $message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" . "Content-Type: text/plain; charset=
\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message .
"\n\n";
      $message .= "--{$mime_boundary}\n";


                $file = fopen($files,"rb");
                $data = fread($file,filesize($files));
                fclose($file);

         $data = chunk_split(base64_encode($data));

          $message .= "Content-Type: {\"application/octet-stream\"};\n" . "
name=\"$files\"\n" .
          "Content-Disposition: attachment;\n" . " filename=\"$files\"\n" .
          "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";

          $message .= "--{$mime_boundary}\n";

$ok = @mail($to, $subject, $message, $headers);
      if ($ok) {
          echo "<p>mail sent to $to!</p>";

      } else {
          echo "<p>mail could not be sent!</p>";
      }

      ?>


Thanks
Regards
Ranjana Srivastava


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to