$('#sendMail').on('click', function () {
let name = $('#name').val().trim();
let face = $('#face').val().trim();
let personal_account = $('#personal_account').val().trim();
let addres = $('#addres').val().trim();
let email = $('#email').val().trim();
let phone = $('#phone').val().trim();
let text = $('#text').val().trim();
$.ajax({
url: '../ajax/mail.php',
type: 'POST',
cache: false,
data: {
"name": name,
"face": face,
"personal_account": personal_account,
"addres": addres,
"email": email,
"phone": phone,
"text": text,
},
dataType: 'html',
beforeSend: function () {
$('#sendMail').prop('disabled', true);
},
success: function(data) {
if (!data)
alert('Были ошибки, сообщение не отправлено')
else
$("#form").trigger('reset')
$('#sendMail').prop('disabled', false);
}
});
});
<?php
$name = $_POST['name']
$face = $_POST['face']
$personal_account = $_POST['personal_account']
$addres = $_POST['addres']
$email = $_POST['email']
$phone = $_POST['phone']
$text = $_POST['text']
$subject = "=?utf-8?B?".base64_encode("Сообщение с сайта")."?=";
$headers = "From: $email\r\nReply-to: $email\r\nContent-Type: text/html; charset=utf-8\r\n"
$success = mail("admin@mail.ru", $subject, $message, $headers)
?>
<form id="form">
<div class="feedback-form">
<div class="feedback-form__name">
<div class="feedback-form__title">Наименование организации / ФИО.*</div>
<input type="text" name="name" id="name" placeholder="Наименование организации / ФИО.*" class="form-input"
required>
</div>
<div class="feedback-form__face">
<div class="feedback-form__title">Контактное лицо</div>
<input type="text" name="face" id="face" placeholder="Контактное лицо" class="form-input">
</div>
<div class="feedback-form__personal-account">
<div class="feedback-form__title">Лицевой счет*</div>
<input type="text" name="personal_account" id="personal_account" placeholder="Лицевой счет*"
class="form-input" required>
</div>
<div class="feedback-form__addres">
<div class="feedback-form__title">Адрес*</div>
<input type="text" name="addres" id="addres" placeholder="Адрес*" class="form-input" required>
</div>
<div class="feedback-form__email">
<div class="feedback-form__title">E-mail*</div>
<input type="email" name="email" id="email" placeholder="E-mail*" class="form-input" required>
</div>
<div class="feedback-form__phone">
<div class="feedback-form__title">Контактный телефон*</div>
<input type="text" name="phone" id="phone" placeholder="Контактный телефон*" class="form-input" id="phone"
value="999 999 99 99" required>
</div>
<div class="feedback-form__text">
<div class="feedback-form__title">Текст сообщения*</div>
<textarea type="text" name="text" id="text" placeholder="Текст сообщения*" class="form-input text"
required></textarea>
</div>
<div class="feedback-form__fail">
<div class="feedback-form__title file">Прикрепить к приложению файл</div>
<input type="file" name="file" id="file" class="inputfile" />
<label for="file" class="input-file">Выбрать файл</label>
</div>
</div>
<button type="button" class="send" id="sendMail">Отправить сообщение</button>
</form>