-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontact.php
More file actions
executable file
·47 lines (39 loc) · 1.39 KB
/
contact.php
File metadata and controls
executable file
·47 lines (39 loc) · 1.39 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
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'vendor/autoload.php'; // PHPMailer ko include kariye
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$mail = new PHPMailer(true);
try {
// SMTP Settings
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'laxucoder@gmail.com'; // 👈 Aapka email
$mail->Password = 'fufr jvae cvuh dnxv'; // 👈 Gmail app password
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port = 587;
// Sender and Recipient
$mail->setFrom($email, $name); // Visitor ka email as sender
$mail->addAddress('laxucoder@gmail.com'); // 👈 Aapko message yaha milega
// Email Content
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = "
<h3>Message from: $name</h3>
<p>Email: $email</p>
<p>Subject: $subject</p>
<p>Message: $message</p>";
$mail->send();
// Redirect after sending
header("Location: thank-you.html");
exit();
} catch (Exception $e) {
echo "Error: {$mail->ErrorInfo}";
}
}
?>