Files
template-for-verstka/send/send.php
2025-02-08 17:07:27 +03:00

67 lines
2.1 KiB
PHP
Raw Permalink 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', 'led-hub.ru');
$mailAddress = 'maxvarvarin3@gmail.com';
$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( 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="'. $_SERVER['SCRIPT_URI'] . '">'. $_SERVER['SCRIPT_URI'] . '</a></p>
';
$mail->isHTML(true);
$mail->Subject = 'Заявка с сайта Вектор';
$mail->Body = $body;
if($mail->send()){
echo json_encode(array('result' => 'success'));
}
}
?>