0

hi frnds..

Here i m trying to attach the file from my webpage..it is working..but when i checking on the mail, the attachment is corrupted like this way..


This is a multi-part message in MIME format.

--==Multipart_Boundary_x58df1ff5254b4812160783d14198c239x
Content-Type:text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

--==Multipart_Boundary_x58df1ff5254b4812160783d14198c239x
Content-Type: application/doc;
name="resume/kishore.doc"
Content-Transfer-Encoding: base64

0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAAAAAAAAAACAAAAhAAAAAAAAAAA
EAAAhgAAAAEAAAD+////AAAAAIIAAACDAAAA////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////s
pcEAcWAJBAAA8BK/AAAAAAAAEAAAAAAABgAAKCQAAA4AYmpianFQcVAAAAAAAAAAAAAAAAAAAAAA
AAAJBBYANWQAABM6AQATOgEAGhwAAAAAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//w8AAAAA
AAAAAAD//w8AAAAAAAAAAAD//w8AAAAAAAAAAAAAAAAAAAAAAKQAAAAAAKILAAAAAAAAogsAAKIL
AAAAAAAAogsAAAAAAACiCwAAAAAAAKILAAAAAAAAogsAABQAAAAAAAAAAAAAALYLAAAAAAAAXh8A
AAAAAABeHwAAAAAAAF4fAAA4AAAAlh8AAKQAAAA6IAAAVAAAALYLAAAAAAAAr3YAACICAACaIAAA
AAAAAJogAAAAAAAAmiAAAAAAAACaIAAAAAAAAJogAAAAAAAA+yEAAAAAAAD7IQAAAAAAAPshAAAA
AAAA8nIAAAIAAAD0cgAAAAAAAPRyAAAAAAAA9HIAAGQAAABYcwAAbAEAAMR0AABsAQAAMHYAACQA
AADReAAAaAIAADl7AAB4AAAAVHYAABUAAAAAAAAAAAAAAAAAAAAAAAAAogsAAAAAAAAKJQAAAAAA
AAAAAAAAAAAAAAAAAAAAAADZIQAAIgAAAPshAAAAAAAACiUAAAAAAAAKJQAAAAAAAFR2AAAAAAAA
AAAAAAAAAACiCwAAAAAAAKILAAAAAAAAmiAAAAAAAAAAAAAAAAAAAJogAAA/AQAAaXYAABYAAAAc
KQAAAAAAABwpAAAAAAAAHCkAAAAAAAAKJQAAlgEAAKILAAAAAAAAmiAAAAAAAACiCwAAAAAAAJog
AAAAAAAA8nIAAAAAAAAAAAAAAAAAABwpAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAACiUAAAAAAADycgAAAAAAAAAAAAAAAAAAHCkAAAAAAAAcKQAA

this is my code..

$headers = array ('From' => $from,'To' => $to,'Subject' => $subject);
$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" ; 



/* First File */ 


$fileatt = "resume/"; // Path to the file                  
$fileatt_type = "application/doc"; // File Type 
$fileatt_name =$fileatt.$resume; // Filename that will be used for the file as the attachment 

$file = fopen($fileatt_name,'rb'); 
$data = fread($file,filesize($fileatt_name)); 
fclose($file); 


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

$email_message .= "--{$mime_boundary}\n" . 
                  "Content-Type: {$fileatt_type};\n" . 
                  " name=\"{$fileatt_name}\"\n" . 
                  //"Content-Disposition: attachment;\n" . 
                  //" filename=\"{$fileatt_name}\"\n" . 
                  "Content-Transfer-Encoding: base64\n\n" . 
                 $data . "\n\n" . 
                  "--{$mime_boundary}\n"; 
unset($data);
unset($file) ;
unset($fileatt); 
unset($fileatt_type); 
unset($fileatt_name);

plz change the code..

thanks in advance..
Sari

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Wraithmanilian
0

Line 1 - $headers treated as an array.

Line 5 - $headers concatenated as a string.

This might have something to do with it...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.