$body = '<h1>Обращение с ссылки в Bio</h1>';
if(trim(!empty($_POST['name']))){
$body.='<p><strong>Имя:</strong> '.$_POST['name'].'</p>';
}
if(trim(!empty($_POST['phone']))){
$body.='<p><strong>Phone:</strong> '.$_POST['phone'].'</p>';
}
if(trim(!empty($_POST['email']))){
$body.='<p><strong>E-mail:</strong> '.$_POST['email'].'</p>';
}
if(trim(!empty($_POST['message']))){
$body.='<p><strong>Сообщение:</strong> '.$_POST['message'].'</p>';
}
// думаю что ошибка где то здесь
if(!empty($_FILES['image']['name'])){
$validAttachments = array();
foreach($_FILES['image']['name'] as $index => $fileName) {
$filePath = $_FILES['image']['tmp_name'][$index];
$validAttachments[] = array($filePath, $fileName);
}
foreach($validAttachments as $attachment) {
$mail->AddAttachment($attachment[0], $attachment[1]);
}
}