I want to attach two image files to an email. However, only the first file gets attached. I've tried all sorts of solutions and still I'm always back in the same spot. Pls can someone help me fix this script so that it works?
<body>
<?php
$fileatttype = "image/jpeg";
$fileattname = "sign.jpg"; //check
$to_addr = "abc@gmail.com";
$from_addr = "comments@gmail.com";
$subject = "Comments/feedback";
$message = '';
$headers = "From: $from_addr\r\n";
$mimetype = 'multipart/mixed';
$filename = 'photo.jpg';
$ffile = 'uploads/photo.jpg';
$fileatt = "uploads/photo.jpg";
$mimetype2 = 'image/jpeg';
$filename2 = 'sign.jpg';
$ffile2 = 'uploads/sign.jpg';
$fileatt2 = "uploads/sign.jpg";
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
$file2 = fopen($fileatt2,'rb');
$data2 = fread($file2,filesize($fileatt2));
fclose($file2);
$unique_sep = md5(uniqid(time()));
$headers .= "Content-Type: {$mimetype}; ".
"name=\"{$filename}\"\n";
$headers .= "Content-Transfer-Encoding: ".
"base64\n";
$headers .= chunk_split(base64_encode($data));
$headers .= "Content-Disposition: attachment\n\n";
$headers .= "--$unique_sep--\r\n";
$headers .= "Content-Type: {$mimetype}; ".
"name=\"{$filename2}\"\n";
$headers .= "Content-Transfer-Encoding: ".
"base64\n";
$headers .= chunk_split(base64_encode($data2));
$headers .= "Content-Disposition: attachment\n\n";
$headers .= "--$unique_sep--";
$success = mail($to_addr, $subject, $message, $headers);
if ($success)
echo "<strong>Your information have been submited.<br>Thank you.</strong>";
else
echo "An error occurred when sending the email to your email address";
?>
</body>