$file = "act.jpg";$fileRead = fopen($file, "r"); // открываем файл
$contentFile = fread($fileRead, filesize($file)); // считываем его до конца
fclose($fileRead); // закрываем файл
$bodyMail .= "Content-Type: application/octet-stream; name==?utf-8?B?".base64_encode(basename($file))."?=\n";
$bodyMail .= "Content-Transfer-Encoding: base64\n"; // кодировка файла
$bodyMail .= "Content-Disposition: attachment; filename==?utf-8?B?".base64_encode(basename($file))."?=\n\n";
$bodyMail .= chunk_split(base64_encode($contentFile))."\n"; // кодируем и прикрепляем файл
$bodyMail .= "--".$separator ."--\n";<?php
var_dump($_POST);
$method = $_SERVER['REQUEST_METHOD'];
$admin_email = "info@antik88.ru";
$file = "act.jpg"; // файл
//Script Foreach
$c = true;
if ( $method === 'POST' ) {
$form_subject = trim($_POST["form_subject"]);
foreach ( $_POST as $key => $value ) {
if ( $value != "" && $key != "project_name" && $key != "admin_email" && $key != "form_subject" ) {
$message .= "
" . ( ($c = !$c) ? '<tr>':'<tr style="background-color: #f8f8f8;">' ) . "
<td style='padding: 10px; border: #e9e9e9 1px solid;'><b>$key</b></td>
<td style='padding: 10px; border: #e9e9e9 1px solid;'>$value</td>
</tr>
";
}
}
} else if ( $method === 'GET' ) {
$project_name = trim($_GET["project_name"]);
$admin_email = trim($_GET["admin_email"]);
$form_subject = trim($_GET["form_subject"]);
$fileRead = fopen($file, "r"); // открываем файл
$contentFile = fread($fileRead, filesize($file)); // считываем его до конца
fclose($fileRead); // закрываем файл
$bodyMail .= "Content-Type: application/octet-stream; name==?utf-8?B?".base64_encode(basename($file))."?=\n";
$bodyMail .= "Content-Transfer-Encoding: base64\n"; // кодировка файла
$bodyMail .= "Content-Disposition: attachment; filename==?utf-8?B?".base64_encode(basename($file))."?=\n\n";
$bodyMail .= chunk_split(base64_encode($contentFile))."\n"; // кодируем и прикрепляем файл
$bodyMail .= "--".$separator ."--\n";
foreach ( $_GET as $key => $value ) {
if ( $value != "" && $key != "project_name" && $key != "admin_email" && $key != "form_subject" ) {
$message .= "
" . ( ($c = !$c) ? '<tr>':'<tr style="background-color: #f8f8f8;">' ) . "
<td style='padding: 10px; border: #e9e9e9 1px solid;'><b>$key</b></td>
<td style='padding: 10px; border: #e9e9e9 1px solid;'>$value</td>
</tr>
";
}
}
}
$message = "<table style='width: 100%;'>$message</table>";
function adopt($text) {
return '=?UTF-8?B?'.Base64_encode($text).'?=';
}
$headers = "MIME-Version: 1.0" . PHP_EOL .
"Content-Type: text/html; charset=utf-8" . PHP_EOL .
'From: '.adopt($project_name).' <'.$admin_email.'>' . PHP_EOL .
'Reply-To: '.$admin_email.'' . PHP_EOL;
mail($admin_email, adopt($form_subject), $message, $headers );
<input name="project_name" id="name" class="form_input" type="text" placeholder="Ваше имя*">
method="post"
<input class="wpcf7-form-control has-spinner wpcf7-submit btn" type="submit" value="Отправить на оценку" />
</p><div class="wpcf7-response-output" aria-hidden="true">
<textarea id="for_message" class="form_textarea" name= "что-то надо написать" placeholder="Ваш вопрос*"></textarea>