Стандартная функция отправки файла.

DavidQuery

Новичок
Добрый день! Подскажите, пожалуйста!
Скрипт работает.
Письмо приходит, но без адресата...
То есть ответить на данное письмо нельзя.

function send_mail($to, $thm, $html, $path) {
$fp = fopen($path,"r");
if (!$fp) {
$response = ['status' => '0', 'error' => "Файл ${path} не может быть прочитан"];
return json_encode($response);
}
$file = fread($fp, filesize($path));
fclose($fp);

$boundary = "--".md5(uniqid(time())); // генерируем разделитель
$headers .= "MIME-Version: 1.0\n";
$headers .= "From: $sitename\n";
$headers .= "Sender: $sender\n";
$headers .="Content-Type: multipart/mixed; boundary=\"$boundary\"\n";
//$headers .= "X-Mailer: PHP/".phpversion();
$multipart .= "--$boundary\n";
$multipart .= "Content-Type: text/html; charset=utf-8";
$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 = \"".basename($path)."\"\n\n";
$message_part .= chunk_split(base64_encode($file))."\n";
$multipart .= $message_part."--$boundary--\n";
if(!mail($to, $thm, $multipart, $headers)) {
$response = "К сожалению, письмо не отправлено";
$response = ['status' => '0', 'error' => "К сожалению, письмо не отправлено"];
return json_encode($response);
}
}
 
Сверху