-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsend_message.php
47 lines (36 loc) · 1.56 KB
/
send_message.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
<!--/////////////////////////////////////////////////////////////////////////////////////////////////
Copyright (c) 2020 - 2025 - Lucky :: Special for LuckyDev.
https://luckydev.xyz/
Title: Personal Development Website for use by Lucky
Format: HTML5 + Bootstrap v3.3.7
This HTML & PHP Codes-work is licensed under:
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)
https://creativecommons.org/licenses/by-nc-sa/4.0/
/////////////////////////////////////////////////////////////////////////////////////////////////-->
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = htmlspecialchars(trim($_POST['name']));
$email = htmlspecialchars(trim($_POST['email']));
$message = htmlspecialchars(trim($_POST['message']));
if (empty($name) || empty($email) || empty($message)) {
echo "All fields are required.";
exit;
}
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo "Invalid email format.";
exit;
}
$to = "contactluckydevelopment@gmail.com";
$subject = "New Contact Form Submission";
$body = "You have received a new message from your website contact form.\n\n".
"Name: $name\n".
"Email: $email\n".
"Message:\n$message";
$headers = "From: $email";
if (mail($to, $subject, $body, $headers)) {
echo "Message sent successfully!";
} else {
echo "Sorry, something went wrong and we couldn't send your message.";
}
}
?>