This commit is contained in:
2024-06-14 16:58:36 +02:00
parent 235c37f17f
commit 252fe7ce44
19 changed files with 1864 additions and 1668 deletions

34
php/send_email.php Normal file
View File

@@ -0,0 +1,34 @@
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Collect form data
$name = htmlspecialchars($_POST['name']);
$email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
$message = htmlspecialchars($_POST['message']);
// Validate email
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo "Invalid email format";
exit;
}
// Email details
$to = "veatio8@gmail.com";
$subject = "New Contact Form Submission";
$headers = "From: " . $email . "\r\n" .
"Reply-To: " . $email . "\r\n" .
"X-Mailer: PHP/" . phpversion();
$body = "Name: $name\n";
$body .= "Email: $email\n\n";
$body .= "Message:\n$message";
// Error handling with detailed information
if (mail($to, $subject, $body, $headers)) {
echo "Email sent successfully!";
} else {
// Use error_get_last() to capture the last error
$error = error_get_last()['message'];
echo "Failed to send email. Error: " . $error;
}
}
?>