You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.5 KiB
52 lines
1.5 KiB
<?php
|
|
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
|
|
|
|
use Bitrix\Main\Config\Option;
|
|
|
|
$response = array();
|
|
|
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|
$name = trim($_POST["name"]);
|
|
$phone = trim($_POST["phone"]);
|
|
|
|
if (empty($name) || empty($phone)) {
|
|
$response = array(
|
|
'success' => false,
|
|
'message' => 'Заполните все поля'
|
|
);
|
|
} else {
|
|
$to = Option::get("main", "email_from");
|
|
|
|
|
|
if (empty($to)) {
|
|
$response = array(
|
|
'success' => false,
|
|
'message' => 'Ошибка конфигурации почты'
|
|
);
|
|
} else {
|
|
// Отправка почты через почтовое событие Битрикс
|
|
CEvent::Send(
|
|
"CONSULTATION_REQUEST",
|
|
SITE_ID,
|
|
array(
|
|
"NAME" => $name,
|
|
"PHONE" => $phone,
|
|
"EMAIL_TO" => $to
|
|
)
|
|
);
|
|
|
|
$response = array(
|
|
'success' => true,
|
|
'message' => 'Заявка успешно отправлена'
|
|
);
|
|
}
|
|
}
|
|
} else {
|
|
$response = array(
|
|
'success' => false,
|
|
'message' => 'Неверный метод запроса'
|
|
);
|
|
}
|
|
|
|
header('Content-Type: application/json');
|
|
echo json_encode($response);
|