sending mail attachment problem
| From: | Angelo Zanetti | Date: | Mon, 15 Nov 2004 14:28:49 +0000 |
| Subject: | sending mail attachment problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-202040@lists.php.net to get a copy of this message | ||
Hi all
I have a script that is supposed to use the mail function to send an
email with an attachment, however, when run the script I dont get any
errors but in the body of the email there is a lot of mixed up text,
which i presume is meant to be the attachment.
Below is the code that performs the sending:
if (file_exists
("/home/httpd/vhosts/myserv.com/httpdocs/pps/" . $row['pps_doc']
.""))
{
$pps_name= $row['pps_doc'];
$pps =
"/home/httpd/vhosts/myserv.com/httpdocs/pps/" . $row['pps_doc'];
$pps_size = $row['pps_size'];
}
$headers .= "From: myserv.com <paul@myserv.com>\r\n";
$headers .= "Content-Type: text/plain;
charset=\"iso-8859-1\"\n";
$headers .= "Content-Transfer-Encoding: 7bit\n\n";
$fp = fopen($pps,'rb');
$file = fread($fp, $pps_size);
/*
Encode The Data For Transition using base64_encode();
And get a 32-character hexadecimal number
*/
$fileContent .= chunk_split(base64_encode($file));
$num = md5( time() );
$headers .= "Content-Type:
application/vnd.ms-powerpoint; \r\n";
$headers.= "name=\"$pps_name\"\r\n";
$headers.= "Content-Transfer-Encoding: base64\r\n";
$headers.= "Content-Disposition: attachment; \r\n";
$headers .= "filename=\"$pps_name\"\r\n\n";
$headers .= $fileContent . "\r\n";
$headers .= "--$num--";
if(!mail($to, $subject, $message, $headers)) {
echo "Error: mail() function failed!<BR>";
}
Im not sure what is causing the problem, the attachment is a powerpoint
slide, Ive tried the various Mime Types for pps, all with the same
result so I presume thats not it thats causing the email to be sent in
the body.
Thanks in advance for any help
Angelo
--------------------------------------------------------------------
Disclaimer
This e-mail transmission contains confidential information,
which is the property of the sender.
The information in this e-mail or attachments thereto is
intended for the attention and use only of the addressee.
Should you have received this e-mail in error, please delete
and destroy it and any attachments thereto immediately.
Under no circumstances will the Cape Technikon or the sender
of this e-mail be liable to any party for any direct, indirect,
special or other consequential damages for any use of this e-mail.
For the detailed e-mail disclaimer please refer to
http://www.ctech.ac.za/polic or call +27 (0)21 460 3911