всеравно не работает, почему на почту приходит пустое письмо??
что я не так сделал?
<?php
$boundary = md5(uniqid(time()));
$mail = "mail";
if(empty($_POST["subject"])
|| empty($_POST["user_mail"])) {
http_response_code(400);
}
$subject = htmlspecialchars($_POST["subject"]);
$backMail = htmlspecialchars($_POST["user_mail"]);
$html = "<html><head></head> <body>" ;
$html .= "Email пользователь:<a href='mailto:{$backMail}'> {$backMail}</a>";
if($_POST["message-text"]) {
$messageText = htmlspecialchars($_POST["message-text"]);
$html .= "<p>Сообщение пользоавателя: </p>" .$messageText;
}
$html .= "</body></html>";
$header = "FROM: 'Online book feeback' <{$mail}> \n";
$header .= "TO: {$mail} \n";
$header .= "Subject: {$subject} \n";
$header .= "Mime-Version: 1.0 \n";
$header .= "Content-Type: multipart/mixed; boundary='{$boundary}' \n";
$body = "--{$boundary} \n";
$body .= "Content-Type: text/html; charset='utf-8' \n";
$body .= "Content-Transfer-Encoding: quoted-printable \n";
$body .= $html;
if(count($_FILES) > 0) {
foreach ($_FILES as $name => $file) {
if(!$file["size"]) continue;
$fopn = fopen($file["tmp_name"], "rb");
$body .= "--{$boundary}\n";
$body .= "Content-Type: application/octet-stream; \n";
$body .= "name=".basename($name)."\n";
$body .= "Content-Transfer-Encoding:base64 \n";
$body .= "Content-Disposition:attachment \n";
$body .= base64_encode(fread($fopn, filesize($file["tmp_name"])));
}
}
$body .= "{$boundary}--";
if(mail($mail, $subject, $body, $header)){
echo "Письмо успешно отправлено";
}
else {
http_response_code(400);
}
?>