I have a small portfolio on imtqy.com. And there is a simple feedback form. Ajax seems to work, since the done function is executed successfully. But the letter does not come to email. I would be very grateful for the answer. Here is the link https://sh-vasyl.imtqy.com

// HTML

<form class="form"> <input type="text" name="name" placeholder="Ваше имя" required> <input type="text" name="email" placeholder="Ваш Е-майл" required> <textarea type="text" name="message" placeholder="Комментарий к заказу</textarea> <button class="btn">Отправить заявку</button> </form> 

// js

 $(".form").submit(function() { var ths = $(this); $.ajax({ type: "GET", url: "mail.php", data: $(this).serialize() }).done(function() { alert("Спасибо за заявку! Скоро мы с вами свяжемся."); setTimeout(function() { ths.trigger("reset"); }, 1000); }); return false; }); 

// Php

 $recepient = "up.vasyl@gmail.com"; $sitename = "Моё Портфолио"; $name = trim($_GET["name"]); $email = trim($_GET["email"]); $text = trim($_GET["message"]); $pagetitle = "Новая заявка с сайта \"$sitename\""; $message = "Имя: $name \nЕмайл: $email \nТекст: $text"; mail($recepient, $pagetitle, $message, "Content-type: text/plain; charset=\"utf-8\"\n From: $recepient"); 

    2 answers 2

    You are in response to the request (it is strange that GET , not POST ) return the contents of the PHP file (GitHub is unlikely to execute arbitrary code on your server). Among other things, do better processing the result through .success() / .error() or handle the response status. Now, even if the server is lying, nothing will not go anywhere, but the user will return that everything is OK.

      On imtqy.com php files are not executed.

      Naturally, the letters will not be sent.