I made a new site, and transferred the handler for the form from the old one, everything works on the old one, when I transferred letters to the post office on the new one, I can’t understand what the problem is
<?php header('Content-Type: text/html; charset=utf-8'); $headers = "MIME-Version: 1.0" . "\r\n" . "Content-type: text/plain; charset=\"utf-8\"" . "\r\n" . "From: =?utf-8?b?". base64_encode($name_from) ."?= <".$mail_from.">" . "\r\n"; $host = $_SERVER['HTTP_HOST']; $first3 = substr($host,0,4); if($first3 === 'www.') $host = substr($host,4,strlen($host)); $domain = ""; if(empty($domain)) $domain = $host; $mail_to = "dmitrobolva12@gmail.com"; $mail_from = "no-reply@".$domain; $name_from = "Трезвый водитель заявка на вакансию"; $phone = htmlspecialchars(stripslashes($_POST['phone'])); $name = htmlspecialchars(stripslashes($_POST['name'])); $age = htmlspecialchars(stripslashes($_POST['age'])); $exp = htmlspecialchars(stripslashes($_POST['exp'])); $place = htmlspecialchars(stripslashes($_POST['place'])); $reg = htmlspecialchars(stripslashes($_POST['reg'])); $msg = htmlspecialchars(stripslashes($_POST['msg'])); $email = htmlspecialchars(stripslashes($_POST['mail'])); $picture = ""; // Если поле выбора вложения не пустое - закачиваем его на сервер if (!empty($_FILES['mail_file']['tmp_name'])) { // Закачиваем файл $path = $_FILES['mail_file']['name']; if (copy($_FILES['mail_file']['tmp_name'], $path)) $picture = $path; } $thm = "$name_from"; $msg=" ФИО: $name<br /> Возраст: $age <br /> Стаж вождения: $exp <br /> Район проживания: $place <br /> Район регистрации: $reg <br /> Email: $email <br /> Телефон: $phone<br />"; $mail_to = "dmitrobolva12@gmail.com"; // Отправляем почтовое сообщение if(empty($picture)) mail($mail_to, $thm, $msg, $headers); else send_mail($mail_to, $thm, $msg, $picture); unlink($picture); // Вспомогательная функция для отправки почтового сообщения с вложением function send_mail($to, $thm, $html, $path) { $fp = fopen($path,"r"); if (!$fp) { print "Файл $path не может быть прочитан"; exit(); } $file = fread($fp, filesize($path)); fclose($fp); $boundary = "--".md5(uniqid(time())); // генерируем разделитель $headers .= "MIME-Version: 1.0\n"; $headers .="Content-Type: multipart/mixed; boundary=\"$boundary\"\n"; $multipart .= "--$boundary\n"; $kod = 'utf-8'; // или $kod = 'windows-1251'; $multipart .= "Content-Type: text/html; charset=$kod\n"; $multipart .= "Content-Transfer-Encoding: Quot-Printed\n\n"; $multipart .= "$html\n\n"; $message_part = "--$boundary\n"; $message_part .= "Content-Type: application/octet-stream\n"; $message_part .= "Content-Transfer-Encoding: base64\n"; $message_part .= "Content-Disposition: attachment; filename = \"".$path."\"\n\n"; $message_part .= chunk_split(base64_encode($file))."\n"; $multipart .= $message_part."--$boundary--\n"; if(!mail($to, $thm, $multipart, $headers)) { echo "К сожалению, письмо не отправлено"; exit(); } } ?>
echo "К сожалению, письмо не отправлено", print moreprint_r(error_get_last()). - Suvitruf ♦