Приветствую гуру кодинга, помогите разобраться с проблемой, сделал форму с прикриплением файла и отправку на почту, на gmail-почту файлы приходят нормально, а на yandex-почту приходят пустые(весом 0 kb). Кто сталкивался , подскажите в чем проблема? С уважение Даниил!
Сам код
<?php
$to_email = "asd@yandex.ru";
if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') {
$output = json_encode(array(
'type'=>'error',
'text' => 'Извините произошла ошибка'
));
die($output);
}
$first_name = filter_var($_POST["first_name"], FILTER_SANITIZE_STRING);
$subject = "Отличные кухни";
if(strlen($first_name)<11){ // If length is less than 4 it will output JSON error.
$output = json_encode(array('type'=>'error', 'text' => 'Введите телефон пожалуйста'));
die($output);
}
$message = '<html><body>';
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= "<tr style='background: #eee;'><td><strong>Телефон:</strong> </td><td>" . strip_tags($_POST['first_name']) . "</td></tr>";
$message .= "</table>";
$message .= "</body></html>";
$file_attached = false;
if(isset($_FILES['file_attach']))
{
$file_tmp_name = $_FILES['file_attach']['tmp_name'];
$file_name = $_FILES['file_attach']['name'];
$file_size = $_FILES['file_attach']['size'];
$file_type = $_FILES['file_attach']['type'];
$file_error = $_FILES['file_attach']['error'];
if($file_error>0)
{
$mymsg = array(
1=>"The uploaded file exceeds the upload_max_filesize directive in php.ini",
2=>"The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form",
3=>"The uploaded file was only partially uploaded",
4=>"No file was uploaded",
6=>"Missing a temporary folder" );
$output = json_encode(array('type'=>'error', 'text' => $mymsg[$file_error]));
die($output);
}
$handle = fopen($file_tmp_name, "r");
$content = fread($handle, $file_size);
fclose($handle);
$encoded_content = chunk_split(base64_encode($content));
$file_attached = true;
}
if($file_attached)
{
$separator = md5(time());
$eol = "\r\n";
$headers = "From: Нашли Кухню вашей мечты? <yadirectoxy@yandex.ru>" . $eol;
$headers .= "MIME-Version: 1.0" . $eol;
$headers .= "Content-Type: multipart/mixed; boundary=\"" . $separator . "\"" . $eol;
$headers .= "Content-Transfer-Encoding: 7bit" . $eol;
$headers .= "This is a MIME encoded message." . $eol;
$body .= "--" . $separator . $eol;
$body .= "Content-type:text/html; charset=utf-8\n";
$body .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$body .= $message . $eol;
$body .= "--" . $separator . $eol;
$body .= "Content-Type:".$file_type." ";
$body .= "Content-Type: application/octet-stream; name=\"" . $file_name . "\"" . $eol;
$body .= "Content-Transfer-Encoding: base64" . $eol;
$body .= "Content-Disposition: attachment; filename=\"".$file_name."\"". $eol;
$body .= $encoded_content . $eol;
$body .= "--" . $separator . "--";
}
else
{
$eol = "\r\n";
$headers = "From: Отличные кухни" . $eol;
$headers .= "Reply-To: ". strip_tags($email_address) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$body .= $message . $eol;
}
$send_mail = mail($to_email, $subject, $body, $headers);
if(!$send_mail)
{
}else{
$output = json_encode(array('type'=>'message', 'text' => 'Спасибо!
<span> Ожидайте звонка :)</span>'));
die($output);
}
?>
<form id="contact-form" method="post" enctype="multipart/form-data">
<div id="response"></div>
<div class="file-upload">
<label>
<input name="file_attach" type="file" required>
<span> Нажмите сюда, <br> чтобы загрузить картинку</span>
</label>
</div>
<input type="text" id="filename" class="filename" disabled>
<input type="tel" class="form-control tel" id="fname" placeholder="Ваш телефон">
<button type="button" id="submit" class="btn btn-accent">Записаться</button>
<span class="politika">Нажимая на данную кнопку Записаться Вы соглашаетесь с <a href="#politika" class="popup-with-form">политикой конфиденциальности</a></span>
</form>