C
cutegirl666888222
Guest
I wrote a php code to send email with attachment, my problem is that the format for the text dont work anymore when I added the code for attachment, I mean <br>, \n dont work, please help
here is the code:
$fileatt = "mypdffile.pdf";
$fileatt_type = "application/pdf";
$fileatt_name = "mypdffile.pdf";
$subject = "Your attached file"; // The Subject of the email
ob_start();
require("emailbody.php"); // i made a simple & pretty page for showing in the email
$body=ob_get_contents(); ob_end_clean();
$description = "Thanks for visiting mysite.com! <br>Here is your free file.<br>";
$description .= "Thanks for visiting.<br> come again";
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$subject .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
$description .= "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" .
$description .= $body."\n\n";
$data = chunk_split(base64_encode($data));
$description .= "--{$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";
here is the code:
$fileatt = "mypdffile.pdf";
$fileatt_type = "application/pdf";
$fileatt_name = "mypdffile.pdf";
$subject = "Your attached file"; // The Subject of the email
ob_start();
require("emailbody.php"); // i made a simple & pretty page for showing in the email
$body=ob_get_contents(); ob_end_clean();
$description = "Thanks for visiting mysite.com! <br>Here is your free file.<br>";
$description .= "Thanks for visiting.<br> come again";
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$subject .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
$description .= "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" .
$description .= $body."\n\n";
$data = chunk_split(base64_encode($data));
$description .= "--{$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";