Repository navigation
Expand file tree
/
Copy pathmodal-send.php
More file actions
38 lines (31 loc) · 1.63 KB
/
Copy pathmodal-send.php
File metadata and controls
38 lines (31 loc) · 1.63 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
<?php
$userName = $_POST['userName'];
$userEmail = $_POST['userEmail'];
$userPhone = $_POST['userPhone'];
// Load Composer's autoloader
require 'phpmailer/PHPMailer.php';
require 'phpmailer/SMTP.php';
require 'phpmailer/Exception.php';
// Instantiation and passing `true` enables exceptions
$mail = new PHPMailer\PHPMailer\PHPMailer();
try {
//Server settings
$mail->SMTPDebug = 0; // Enable verbose debug output
$mail->isSMTP(); // Send using SMTP
$mail->Host = 'smtp.gmail.com'; // Set the SMTP server to send through
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'xomix01@gmail.com'; // SMTP username
$mail->Password = 'wsxedcqaz132'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` also accepted
$mail->Port = 465; // TCP port to connect to
//Recipients
$mail->setFrom('xomix01@gmail.com', 'Lead');
$mail->addAddress('movsar.kh.128@gmail.com'); // Add a recipient
// Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'New Lead';
$mail->Body = "Имя пользователя: ${userName}, его телефон: ${userPhone}. Его почта: ${userEmail}";
$mail->send();
} catch (Exception $e) {
echo "Письмо не отправлено, есть ошибка. Код ошибки: {$mail->ErrorInfo}";
}