Кусок кода для размышлений
// ... //
$mb = md5(uniqid(time()));
$mail_arr = array(1=> "m_kng@mail.ru");
$to = $mail_arr[1];
$subject = 'Письмо с сайта';
$header = 'X-Mailer: PHP' . PHP_EOL . 'Reply-To: ' . $email . PHP_EOL . 'MIME-Version: 1.0' . PHP_EOL . 'Content-Type: multipart/mixed; ' . PHP_EOL . 'boundary="----------' . $mb . '"' . PHP_EOL;
$body .= '------------' . $mb . PHP_EOL . 'Content-type: text/plain; charset=utf-8' . PHP_EOL . 'Content-Transfer-Encoding: quoted-printable' . PHP_EOL . 'Письмо от:' . $name . PHP_EOL . 'Адрес для ответа:' . $email . PHP_EOL . $mess . PHP_EOL . 'Инф: UA - ' . getua() . ' IP - ' . $_SERVER['REMOTE_ADDR'] . ' (' . getip() . ')' . PHP_EOL;
if (isset($_FILES['uplfile'])) {
foreach ($_FILES['uplfile']['error'] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$body .= '------------' . $mb . PHP_EOL . 'Content-Type: ' . $_FILES['uplfile']['type'][$key] . ';' . PHP_EOL . ' name="' . $_FILES['uplfile']['name'][$key] . '"' . PHP_EOL . 'Content-Disposition: attachment;' . PHP_EOL . ' filename="' . $_FILES['uplfile']['name'][$key] . '"' . PHP_EOL . 'Content-Transfer-Encoding: base64' . PHP_EOL . chunk_split(base64_encode(file_get_contents($_FILES['uplfile']['tmp_name'][$key]))) . PHP_EOL;
}
}
}
$body .= '------------' . $mb . '--';
if (mail_utf8($to, $subject, $body, $header)) {
echo '<div>Ваше сообщение будет рассмотрено в ближайшие сроки</div>';
echo '<div><a href="./">назад</a></div>';
} else {
echo '<div>Произошла ошибка</div>';
echo '<div><a href="./">назад</a></div>';
}
// ... //