anushka Posted April 21, 2008 Share Posted April 21, 2008 Hey guys i am able to read one image attachment but when i go for mutiple images attachment i am not able to read The code which i have written is below can anyone tel me how to use multiple images <?php // ini_set("sendmail_from", $from); //$fname1="ashok.jpg"; //$fname2="ashok1.jpg"; $from="[email protected]"; $to="[email protected]"; $body="sending mail attachment"; $subject="send an attachment"; $fileatt1 = "c:/websites/abc/testing/ashok/all/1208518212.jpg"; // Path to the file $fileatt_type = "application/octet-stream"; // File Type $fileatt_name1 = $fname1; // Filename that will be used for the file as the attachment $fileatt2 = "c:/websites/abc/testing/ashok/all/1208518222.jpg"; // Path to the file $fileatt_type = "application/octet-stream"; // File Type $fileatt_name2 = $fname2; // Filename that will be used for the file as the attachment $email_from = $from; // Who the email is from $email_subject = $subject; // The Subject of the email $email_txt = $body; // Message that the email has in it if(!$cc=="") { $headers .= "Cc: $cc\r\n"; } if(!$bcc=="") { $headers .= "Bcc: $bcc\r\n"; } $headers .= "From: $from\r\n"; $headers .= "To: $to\r\n"; $headers = "From: ".$email_from; /* $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); */ $file1 = fopen($fileatt1,'rb'); $data1 = fread($file,filesize($fileatt1)); fclose($file1); $file2 = fopen($fileatt2,'rb'); $data2= fread($file,filesize($fileatt2)); fclose($file2); $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; $email_message1 .= "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_message1 . "\n\n"; $data1 = chunk_split(base64_encode($data1)); $data2 = chunk_split(base64_encode($data2)); $email_message1 .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type1};\n" . " name=\"{$fileatt_name1}\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data1 . "\n\n" . "--{$mime_boundary}--\n"; //second header $email_message1 .= "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_message1 . "\n\n"; //$data = chunk_split(base64_encode($data)); $email_message1.= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type2};\n" . " name=\"{$fileatt_name}\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data2 . "\n\n" . "--{$mime_boundary}--\n"; $email_message2 .= "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_message2 . "\n\n"; //$data1 = chunk_split(base64_encode($data1)); //$data2 = chunk_split(base64_encode($data2)); $email_message2 .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type1};\n" . " name=\"{$fileatt_name}\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt_name2}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data1 . "\n\n" . "--{$mime_boundary}--\n"; //second header $email_message2 .= "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_message2 . "\n\n"; //$data = chunk_split(base64_encode($data)); $email_message2.= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type2};\n" . " name=\"{$fileatt_name}\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data2 . "\n\n" . "--{$mime_boundary}--\n"; $email_message=$email_message1.$email_message2; $ok =@mail($to, $email_subject, $email_message, $headers); if($ok) { echo "<font face=verdana size=2>The file was successfully sent!</font>"; } else { die("Sorry but the email could not be sent. Please go back and try again!"); } ?> Link to comment https://forums.phpfreaks.com/topic/102080-i-am-able-to-read-one-image-attachment-but-not-mutiple-images-attachment/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.