Hmmmm - there are quite a few major problems with this code, as well as a few minor ones. The minor ones are pretty easy to sort - your "T-Variables error" is because the way you are referencing an array makes no sense: -
$fileatt[$s]_type
doesn't mean anything, it isn't valid php afaik. In fact, I don't see much point in the first loop: -
for($p = 0; $p<11; $p++)
{
$s = $p + 1;
$fileatt[$s] = $_FILES['fileatt[$s]']['tmp_name'];
$fileatt[$s]_type = $_FILES['fileatt[$s]']['type'];
$fileatt[$s]_name = $_FILES['fileatt[$s]']['name'];
}
which is just copying from one array to another (actually - it doesn't look like it would even work doing that tbh). At the end of the day, you could just use the $_FILES array throughout your code instead.
Next, we get to the attachment of file data: -
// Base64 encode the file data
$data = chunk_split(base64_encode($data));
// Add file attachment to the message
for($m = 0; $m<11; $m++)
{
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name[".($m + 1)."]}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data[($m + 1)] . "\n\n" .
"--{$mime_boundary}--\n";
}
which I'm not sure i understand whatyou are doing. You have read all the files into an array $data. Then you base64 enocde the whole $data array (which I dont know what would happen on an array). So - ALL the files are ending up as one base64 encoded string which of course is never going to work, and no one would know what to do with.
What you need to do is move the encoding into the loop below it and only encode one file at a time: -
// Add file attachment to the message
for($m = 0; $m<11; $m++)
{
// Base64 encode the file data
$file_data = chunk_split(base64_encode($data[($m+1)]));
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name[".($m + 1)."]}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$file_data . "\n\n" .
"--{$mime_boundary}--\n";
}
and finally (just a stoopid point), when calling the [man]mail/man function, drop the $message parameter and call it with an empty string, since in this case the headers we are using ARE the message body: -
mail($to, $subject, '', $headers);
Hopefully this will help you in the right direction.... i haven't tested anything i've changed above so apologies if i've got anything wrong.
🙂