Dronealone
IS-IT--Management
Hello,
I am trying to attach a PDF to an email. It is attaching the PDF ok, but it also attaches a plain text file called something like ATT000035.txt. Any ideas how to get rid of this?? The code I am using is below:
case "PDF":
if (is_uploaded_file($file))
{
// Read the file to be attached ('rb' = read binary)
$fileopen = fopen($file,'rb');
$data = fread($fileopen,filesize($file));
fclose($fileopen);
// Generate a boundary string
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// Add the headers for a file attachment
// Add a multipart boundary above the plain message
$headers .= "MIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
$message = "Please find your current issue of Insider Week attached.\n\nRegards,\n\nThe Insurance Insider.\n\n" . "--{$mime_boundary}\n";
$message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n";
// Base64 encode the file data
$data = chunk_split(base64_encode($data));
// Add file attachment to the message
$message .= "--{$mime_boundary}\n" . "Content-Type: {$file_type};\n" . " name=\"{$file_name}\"\n";
$message .= "Content-Disposition: attachment;\n" . " filename=\"{$file_name}\"\n";
$message .= "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n";
}
for ($i = 0; $i < count($recipient); $i++)
{
mail($recipient[$i], $subject, $message, $headers);
}
break;
Thanks!!
I am trying to attach a PDF to an email. It is attaching the PDF ok, but it also attaches a plain text file called something like ATT000035.txt. Any ideas how to get rid of this?? The code I am using is below:
case "PDF":
if (is_uploaded_file($file))
{
// Read the file to be attached ('rb' = read binary)
$fileopen = fopen($file,'rb');
$data = fread($fileopen,filesize($file));
fclose($fileopen);
// Generate a boundary string
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// Add the headers for a file attachment
// Add a multipart boundary above the plain message
$headers .= "MIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
$message = "Please find your current issue of Insider Week attached.\n\nRegards,\n\nThe Insurance Insider.\n\n" . "--{$mime_boundary}\n";
$message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n";
// Base64 encode the file data
$data = chunk_split(base64_encode($data));
// Add file attachment to the message
$message .= "--{$mime_boundary}\n" . "Content-Type: {$file_type};\n" . " name=\"{$file_name}\"\n";
$message .= "Content-Disposition: attachment;\n" . " filename=\"{$file_name}\"\n";
$message .= "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n";
}
for ($i = 0; $i < count($recipient); $i++)
{
mail($recipient[$i], $subject, $message, $headers);
}
break;
Thanks!!