<?php

require_once("../../../wp-load.php");

$full_name = $_POST['name'];
$mail = $_POST['mail'];
$phone = $_POST['phone'];
$the_message = $_POST['message'];

$message .= "Name: " . $full_name . "\n";
$message .= "E-mail address: " . $mail . "\n";
$message .= "Phone: " . $phone . "\n";
$message .= "Message: " . $the_message;

$domain = get_site_url();
$domain = str_replace("http://", "", $domain);
$domain = str_replace("www.", "", $domain);

$headers= "From: Mitić Regalo Nameštaj <contact@" . $domain . ">\r\n";

if(mail('redler.tamas@gmail.com', "New message", $message,$headers)) {

if($_GET['lang'] == "hu") {
echo "<div class=\"mail-msg\"><img src=\"" . get_template_directory_uri() . "/images/ok.png\">Üzenetét sikeressen elküldtük!</div>";
} else {
echo "<div class=\"mail-msg\"><img src=\"" . get_template_directory_uri() . "/images/ok.png\">Vaša poruka je uspešno poslata!</div>";
}

} else {
if($_GET['lang'] == "hu") {
echo "<div class=\"mail-msg\"><img src=\"" . get_template_directory_uri() . "/images/fail.png\">Hiba történt az üzenet küldése közben. Kérjük próbálja később!</div>";
} else {
echo "<div class=\"mail-msg\"><img src=\"" . get_template_directory_uri() . "/images/fail.png\">Poruka nije poslata! Molimo pokušajte kasnije!</div>";
}
}

?>