-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess.php
More file actions
50 lines (42 loc) · 1.73 KB
/
process.php
File metadata and controls
50 lines (42 loc) · 1.73 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
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
require 'PHPMailer/Exception.php';
require 'PHPMailer/PHPMailer.php';
require 'PHPMailer/SMTP.php';
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST["name"];
$email = $_POST["email"];
$message = $_POST["message"];
// Create a PHPMailer object
$mail = new PHPMailer(true);
try {
// Server settings
$mail->SMTPDebug = SMTP::DEBUG_OFF; // You can change this to DEBUG_SERVER for more information
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com'; // Your SMTP server address
$mail->SMTPAuth = true;
$mail->Username = 'keanuh20org@gmail.com'; // Your SMTP username
$mail->Password = 'HomeSweetHome2022@'; // Your SMTP password
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; // Enable TLS encryption
$mail->Port = 587; // TCP port to connect to
// Sender and recipient settings
$mail->setFrom('keanuh20org@gmail.com', 'Keanu.Dev system');
$mail->addAddress('keanu@gameunit.nl', 'Keanu van der Bie');
// Email content
$mail->isHTML(false);
$mail->Subject = 'New Contact Form Submission';
$mail->Body = "You have received a new contact form submission from $name ($email):\n\n$message";
// Send email
$mail->send();
// Redirect back to the contact form with a success message
header("Location: contact.php?success=true");
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
} else {
// If the form wasn't submitted via POST, redirect back to the contact form
header("Location: contact.php");
}
?>