-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmail.php
98 lines (74 loc) · 2.29 KB
/
mail.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
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
require 'components/connect.php'; // Include the database connection
use PHPMailer\PHPMailer\PHPMailer;
require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';;
// Use PHPMailer to send the email
$mail = new PHPMailer();
// Gmail SMTP configuration
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'soukainasbai77@gmail.com';
$mail->Password = 'jltaynfdmrvhoenr';
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port = 587;
$name = $_POST['name'];
$Address = $_POST['Address'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
// Email content
$mail->setFrom($email, $name);
$mail->addAddress('soukainasbai77@gmail.com');
$mail->isHTML(true);
$mail->Subject = 'Contact Form Submission';
$mail->Body = "Name: {$name}\nAddress: {$Address}\nEmail: {$email}\nPhone: {$phone}\nMessage: {$message}";
// Try to send the email
if ($mail->send()) {
echo '<script>alert("Mail sent successfully!");</script>';
} else {
echo '<script>alert("Mail not sent. Error: ' . $mail->ErrorInfo . '");</script>';
}
?>
<!--echo '
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>contact</title>
<style>
a{
color :#828282;
font-style: italic;
}
a.hover{
color:#fff;
}
</style>
<!-- font awesome cdn link -
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css">
<!-- custom css file link -
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/footer.css">
<script
src="https://kit.fontawesome.com/64d58efce2.js"
crossorigin="anonymous"
></script>
</head>
<body>
<!-- header section starts -
<!-- header section ends -
<div class="container">
<h1>Thank you for contacting me. I will back to you as soon as possible!</h1>
<p class="back">Go back to the <a href="home.php">homepage</a>.</p>
</div></div>
<!-- custom js file link -
<script src="js/script.js"></script>
</body>
</html>
';
?>-->