Files
template-for-verstka/send/send.php
Константин Белан 18e2e45585 init
2024-09-13 00:43:42 +07:00

73 lines
2.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// ini_set('display_errors', 1);
// error_reporting(E_ALL);
require 'phpmailer/PHPMailer.php';
require 'phpmailer/SMTP.php';
require 'phpmailer/Exception.php';
if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
$mail = new PHPMailer\PHPMailer\PHPMailer();
$mail->SMTPDebug = 0;
// $mail->isSMTP();
$mail->SMTPAuth = true;
$mail->CharSet = 'utf-8';
$mail->Host = 'mail.hosting.reg.ru';
$mail->Username = 'admin@dezhub.ru';
$mail->Password = 'vM7hA0vS0qmL1qQ4';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
// $mail->setFrom('noreply@vectortomsk.ru', 'Вектор');
$mail->setFrom('noreply@ledoffsky.agency', 'Вектор');
$mailAddress = 'kosbelan@yandex.ru';
$mail->addAddress($mailAddress);
$message = '';
foreach($_POST as $key => $value) {
preg_match("/name/", $key, $match);
if (strpos($key, 'name') !== false) {
$key = 'Имя:';
}
if (strpos($key, 'tel') !== false) {
$key = 'Номер телефона:';
}
if (strpos($key, 'types') !== false) {
$key = 'Тип блока:';
}
if (strpos($key, 'quantity') !== false) {
$key = 'Количество:';
}
if( empty($value) ) {
$key = '';
$value = '';
}
$message .= "<tr><td style='background:#f5f5f5;border-radius:10px;'><b>".$key."</b></td><td>".$value."</td></tr>";
};
$body = '
<table cellpadding="10" cellspacing="5" style="border:1px solid #ebebeb;border-radius:10px;">
<tbody>
'. $message .'
</tbody>
</table>
<p>Отправлено с сайта: <a href="https://vectortomsk.ru/">Вектор</a></p>
';
$mail->isHTML(true);
$mail->Subject = 'Заявка с сайта Вектор';
$mail->Body = $body;
if($mail->send()){
echo json_encode(array('result' => 'success'));
}
}
?>