Здравствуйте прошу помощи, не могу разобраться а чем причина почему не приходят сообщения с формы на почту!
Помогите пожалуйста!
Сам скрипт JS
$("#form_1").submit(function() {
var e = $(this),
o = !1;
if (e.find(".required").each(function() {
"" == $(this).val() && ($(this).addClass("err"), o = !0)
}), !o) {
var n = $("#num_1").val(),
t = $("#name_1").val(),
a = $("#tel_1").val(),
i = $("#mail_1").val();
$.ajax({
type: "POST",
url: "send.php",
data: "&num=" + n + "&name=" + t + "&tel=" + a + "&mail=" + i,
success: function() {
$("#overlay").fadeIn(200, function() {
$("#thank").css("display", "block").animate({
opacity: 1,
top: "50%"
}, 400)
})
},
error: function() {}
}), $("#form_1 input").val(""), e.find(".required").each(function() {
$(this).removeClass("err")
})
}
}), $("#form_2").submit(function() {
var e = $(this),
o = !1;
if (e.find(".required").each(function() {
"" == $(this).val() && ($(this).addClass("err"), o = !0)
}), !o) {
var n = $("#num_2").val(),
t = $("#name_2").val(),
a = $("#tel_2").val(),
i = $("#mail_2").val();
$.ajax({
type: "POST",
url: "send.php",
data: "&num=" + n + "&name=" + t + "&tel=" + a + "&mail=" + i,
success: function() {
$("#overlay").fadeIn(200, function() {
$("#thank").css("display", "block").animate({
opacity: 1,
top: "50%"
}, 400)
})
},
error: function() {}
}), $("#form_2 input").val(""), e.find(".required").each(function() {
$(this).removeClass("err")
})
}
}), $("#pop_form").submit(function() {
var e = $(this),
o = !1;
if (e.find(".required").each(function() {
"" == $(this).val() && ($(this).addClass("err"), o = !0)
}), !o) {
var n = $("#num_3").val(),
t = $("#name_3").val(),
a = $("#tel_3").val(),
i = $("#mail_3").val();
$.ajax({
type: "POST",
url: "send.php",
data: "&num=" + n + "&name=" + t + "&tel=" + a + "&mail=" + i,
success: function() {
$("#pop_form").animate({
opacity: 0,
top: "35%"
}, 200), $("#thank").delay(300).css("display", "block").animate({
opacity: 1,
top: "50%"
}, 400)
},
error: function() {}
}), $("#pop_form input").val(""), e.find(".required").each(function() {
$(this).removeClass("err")
})
}
}),
Сам php (думаю в нем проблема он универсальный)
<?php
$method = $_SERVER['REQUEST_METHOD'];
//Script Foreach
$c = true;
if ( $method === 'POST' ) {
$project_name = trim($_POST["project_name"]);
$admin_email = trim($_POST["admin_email"]);
$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"]);
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 );
Ну и HTML
<div class="gr" id="catch_1">
<div class="container">
<form id="form_1" method="post" action="javascript:void(null);">
<h3>НАЗВАНИЕ</h3>
<p>ЗАГОЛОВОК</p>
<input type="hidden" name="project_name" value="НАЗВАНИ">
<input type="hidden" name="admin_email" value="ПОЧТА">
<input type="hidden" name="form_subject" value="Заявка з сайта.">
<input id="num_1" type="hidden" value="second_form">
<span><input class="required" id="name_1" placeholder="ВАШЕ ИМЯ" type="text"></span>
<span><input id="mail_1" placeholder="E-MAIL" type="text"></span>
<span><input id="tel_1" placeholder="ТЕЛЕФОН" class="required tel" type="text"></span>
<div class="clr"></div>
<button type="submit">КНОПКА</button>
</form>
</div>
</div>
Таких форм у меня 3
<div class="gr" id="catch_2">
<div class="container">
<form id="form_2" method="post" action="javascript:void(null);">
<h3>НАЗВАНИЕ</h3>
<p>ЗАГОЛОВОК</p>
<input type="hidden" name="project_name" value="НАЗВАНИЕ">
<input type="hidden" name="admin_email" value="ПОЧТА">
<input type="hidden" name="form_subject" value="Заявка з сайта.">
<input id="num_2" type="hidden" value="penult_form">
<span><input class=" required" id="name_2" placeholder="ВАШЕ ИМЯ" type="text"></span>
<span><input id="mail_2" placeholder="E-MAIL" type="text"></span>
<span><input id="tel_2" placeholder="ТЕЛЕФОН" type="text" class="tel required"></span>
<button type="submit">КНОПКА</button>
</form>
</div>
</div>