Untitled

 avatar
unknown
plain_text
2 years ago
799 B
3
Indexable
<?php
// Set the recipient email address here
$recipient = "info@onetree.sk";

// Get the form fields and remove whitespace
$name = trim($_POST["name"]);
$email = trim($_POST["email"]);
$message = trim($_POST["message"]);

// Get the IP address of the user submitting the form
$ip = $_SERVER['REMOTE_ADDR'];

// Validate the email address
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
  echo "Nesprávny formát.";
  exit;
}

// Build the email message
$subject = "Predmet : $name";
$body = "Meno : $name\nE-Mail: $email\nIP Adresa : $ip\n\nSpráva :\n\n$message";

// Send the email
$headers = "From: $email\r\n";
$headers .= "Reply-To: $email\r\n";
if (mail($recipient, $subject, $body, $headers)) {
  echo "Ďakujeme za vašu správu.";
} else {
  echo "Pri odosielaní nastala chyba.";
}
?>