-
Notifications
You must be signed in to change notification settings - Fork 0
/
submit-inquery.php
37 lines (28 loc) · 1.18 KB
/
submit-inquery.php
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
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'vendor/autoload.php';
$mail = new PHPMailer(true);
try {
// SMTP configuration
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'foramdelvadiya@gmail.com'; // Your email
$mail->Password = 'nhtg hqft xsps isqj'; // Your password or App Password
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; // Enable TLS
$mail->Port = 587; // TCP port to connect to
// Recipients
$mail->setFrom('foramdelvadiya@gmail.com', $_REQUEST['name']);
$mail->addAddress('recipient@example.com');
// Email content
$mail->isHTML(true);
$mail->Subject = 'Inquery Details';
$html = 'Name : '. $_REQUEST['name'].'<br>'.'Email : '.$_REQUEST['email'].'<br>'.'Phone Number : '.$_REQUEST['phone'].'<br>'.'Description : '.$_REQUEST['desc'];
$mail->Body = $html;
// Send the email
$mail->send();
echo json_encode(value: ["message" => "Your inquiry has been submitted successfully."]);
} catch (Exception $e) {
echo json_encode(value: ["message" => "Your inquiry has been not submitted. EMailerrror: {$mail->ErrorInfo}"]);
}