I can only receive the first atatchment, and the second atatchment are always
name as ATTXxX with 0k only....how come???
ATT00001 (0.0 KB), firstfile.doc (96.6 KB)
thanks.
Expand|Select|Wrap|Line Numbers
- $num = md5(time());
- $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
- //Normal headers
- $headers = "From: AAA<ad@aaa.com>\r\n";
- $headers .= "MIME-Version: 1.0\r\n";
- $headers .= "Content-Type: multipart/mixed; ";
- $headers .= "boundary=".$num."\r\n";
- $headers .= "--$num\r\n";
- // This two steps to help avoid spam
- $headers .= "Message-ID: <".gettimeofday()." TheSystem@".$_SERVER['SERVER_NAME'].">\r\n";
- $headers .= "X-Mailer: PHP v".phpversion()."\r\n";
- // With message
- $headers .= "Content-Type: text/html; charset=iso-8859-1\r\n";
- $headers .= "Content-Transfer-Encoding: 8bit\r\n";
- $headers .= "".$message."\n";
- $headers .= "--".$num."\n";
- /* firstFile */
- $fileatt = $_FILES['emailsentmsg']['name']; // Path to the file
- $fileatt_type = $_FILES['emailsentmsg']['type'];
- $fileatt_temp = $_FILES['emailsentmsg']['tmp_name'];
- $fileatt_size = $_FILES['emailsentmsg']['size'];
- $fileatt_name = $fileatt; // Filename that will be used for the file as the attachment
- $fp = fopen($fileatt_temp,'rb');
- $file = fread($fp, $fileatt_size);
- $file = chunk_split(base64_encode($file));
- // Attachment headers
- $headers .= "--{$mime_boundary}\n" .
- $headers .= "Content-Type:".$fileatt_type." ";
- $headers .= "name=\"".$fileatt_name."\"r\n";
- $headers .= "Content-Transfer-Encoding: base64\r\n";
- $headers .= "Content-Disposition: attachment; ";
- $headers .= "filename=\"".$fileatt_name."\"\r\n\n";
- $headers .= "".$file."\r\n";
- $headers .= "--{$mime_boundary}\n";
- fclose($fp);
- unset($file);
- unset($fileatt);
- unset($fileatt_type);
- unset($fileatt_name);
- /* second File */
- if ($emailsentmsg0){
- $fileatt = $_FILES['emailsentmsg0']['name']; // Path to the file
- $fileatt_type = $_FILES['emailsentmsg0']['type'];
- $fileatt_temp = $_FILES['emailsentmsg0']['tmp_name'];
- $fileatt_size = $_FILES['emailsentmsg0']['size'];
- $fileatt_name = $fileatt; // Filename that will be used for the file as the attachment
- $fp = fopen($fileatt_temp,'rb');
- $file = fread($fp, $fileatt_size);
- $file = chunk_split(base64_encode($file));
- // Attachment headers
- //$headers .= "--{$mime_boundary}\n" .
- $headers .= "Content-Type:".$fileatt_type." ";
- $headers .= "name=\"".$fileatt_name."\"r\n";
- $headers .= "Content-Transfer-Encoding: base64\r\n";
- $headers .= "Content-Disposition: attachment; ";
- $headers .= "filename=\"".$fileatt_name."\"\r\n\n";
- $headers .= "".$file."\r\n";
- $headers .= "--{$mime_boundary}\n";
- fclose($fp);
- unset($file);
- unset($fileatt);
- unset($fileatt_type);
- unset($fileatt_name);
- }
- $oksent = mail($emailto, $subject, $message, $headers);