php mail attachments weird behaviour

Eatfleann

New Member
I need some help here with a really weird situation.. i made a webmail form to send emails with multiple attachments, it worked out of the box yesterday but today it only sends 1 file as an attachment and not multiple. O_O I revert my SVN to an older revision also and the problem still persists, any idea? this is really weird.. how working stuff brake from one day to another, i think the problem must be the SMTP server or something. Help please!Code:\[code\] $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $attachments = TRUE; $body = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=iso-8859-1\n" . "Content-Transfer-Encoding: 7bit\n\n" . $body . "\n\n"; $body .= "--{$mime_boundary}\n"; $attach = array(); for($i=0; $i<count($_FILES['file']['name']);$i++) { $tmp_name = $_FILES['file']['tmp_name'][$i]; $type = $_FILES['file']['type'][$i]; $name = $_FILES['file']['name'][$i]; $size = $_FILES['file']['size'][$i]; if (file_exists($tmp_name)){ $kb = $size/1024; $kbSize = round($kb*100)/100; if(is_uploaded_file($tmp_name)){ $file = fopen($tmp_name,'rb'); $fdata = http://stackoverflow.com/questions/3831371/fread($file,filesize($tmp_name)); //stream file to var and send it in headers fclose($file); $fdata = chunk_split(base64_encode($fdata)); $body .="Content-Type: {\"application/octet-stream\"};\n" . " name=\"$name\"\n" . "Content-Disposition: attachment;\n" . " filename=\"$name\"\n" . "Content-Transfer-Encoding: base64\n\n" . $fdata . "\n\n"; $body .= "--{$mime_boundary}-\n"; } } } $sent = myMailer::sendAttached($from,$to,$subject,$body,$mime_boundary,$multi);\[/code\]MyMailer class, sendAttached Method:\[code\] public static function sendAttached($from,$to,$subject,$body,$mime,$multi=FALSE){ $headers = 'From: Website <'.$from.'>'. "\r\n". 'Reply-To: '.$from. "\r\n". "MIME-Version: 1.0\r\n" . "Content-Type: multipart/mixed;\r\n" . " boundary=\"{$mime}\""; if($multi == TRUE && is_array($to)){ foreach($to as $item) { mail(trim($item),$subject,$body,$headers); } return TRUE; }else{ return mail($to,$subject,$body,$headers); }}\[/code\]
 
Back
Top