Hi,
i'm trying to send emails with attachment but i get an error
at $file = fread($fp, $att_size);
and i don't understand why, any help is appreciated.
code is below
$subject = $_REQUEST['subject'];
$cc = $_REQUEST['cc'];
$from = $_REQUEST['from'];
$message = $_REQUEST['text'];
$att = $_FILES['attachment'];
$filename = "/home/prog/www/phpmail.txt";
$handle = fopen ($filename, "r");
$fp = fopen($att_name, "r");
$file = fread($fp,$att_size);
$file = chunk_split(base64_encode($file));
$num = md5( time() );
$hdr = "From:$from\r\n";
$hdr .= "CC:$cc\r\n";
$hdr .= "MIME-Version: 1.0\r\n";
$hdr .= "Content-type: multipart/mixed; ";
$hdr .= "boundary=$num \r\n";
$hdr .= "--$num\r\n";
$hdr .= "Content-type: text/plain\r\n";
$hdr .= "Content-Transfer-Encoding: 8bit\r\n\n";
$hdr .= "$message\r\n";
$hdr .= "--$num\n";
$hdr .= "Content-type: $att_type; ";
$hdr .= "name=\"$att_name\"\r\n";
$hdr .= "Content-Transfer-Encoding: base64\r\n";
$hdr .= "Content-Disposition: attachment; ";
$hdr .= "filename=\"$att_name\"\r\n\n";
$hdr .= "$file\r\n";
$hdr .= "--$num--";
do{
$data = fread($handle, 128);
if (strlen($data) == 0) {
break;
}
mail($data,$subject,"",$hdr);
print "done to $data with attachment";
}while(true);
fclose($handle);
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php