-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmail.php
More file actions
63 lines (47 loc) · 2.07 KB
/
mail.php
File metadata and controls
63 lines (47 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'phpmailer/src/Exception.php';
require 'phpmailer/src/PHPMailer.php';
require 'phpmailer/src/SMTP.php';
$mail = new PHPMailer(true);
$mail->isSMTP(); //Send using SMTP
$mail->Host = 'smtp.mail.ru'; //Set the SMTP server to send through
$mail->SMTPAuth = true; //Enable SMTP authentication
$mail->Username = 'bonlinelending@mail.ru'; //SMTP username
$mail->Password = 'Cu61PVEU'; //SMTP password
$mail->SMTPSecure = 'ssl'; //Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
$mail->Port = 465; //TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above
$mail->setFrom('bonlinelending@mail.ru');
$mail->addAddress('dveriplusmebel@gmail.com');
$mail->CharSet = 'UTF-8';
$mail->setLanguage('ru', 'phpmailer/language/');
$mail->IsHTML(true);
//Тема письма
$mail->Subject = 'Заявка с сайта "Бонлайн кровати"';
//Тело письма
$body = '<h1>Заявка с сайта "Бонлайн кровати</h1>';
if (trim(!empty($_POST['name']))) {
$body .= '<p><strong>Имя: </strong>' . $_POST['name'] . '</p>';
}
if (trim(!empty($_POST['surname']))) {
$body .= '<p><strong>Фамилия: </strong>' . $_POST['surname'] . '</p>';
}
if (trim(!empty($_POST['phone']))) {
$body .= '<p><strong>Телефон: </strong>' . $_POST['phone'] . '</p>';
}
if (trim(!empty($_POST['mail']))) {
$body .= '<p><strong>Почта: </strong>' . $_POST['mail'] . '</p>';
}
if (trim(!empty($_POST['message']))) {
$body .= '<p><strong>Сообщение: </strong>' . $_POST['message'] . '</p>';
}
$mail->Body = $body;
if (!$mail->send()) {
$message = 'Ошибка';
} else {
$message = 'Данные отправлены!';
}
$response = ['message' => $message];
header('Content-type: application/json');
echo json_encode($response);