0

I want to send form on email and I don't understand why this code not work. giving 200 OK On other site email can be sent php echo and echo json_encode() not show in response. EMail correct.

NOTE: A message stating that this question has a lot of code, and more information should write just got. I'm sorry, I'm here copypaste text.

HTML

     <form  role="form" id="contactform" method="POST">
            <div class="form-group">
                 <input type="text" class="form-control" id="name" placeholder="Ваше имя" name="name">
            </div>
            <div class="form-group">
                 <input type="text" class="form-control" id="phone" placeholder="Контактный номер телефона" name="phone">
            </div>
            <div class="form-group">
            <input type="text" class="form-control" id="city" placeholder="Город" name="city">
            </div>
            <div class="form-group">
                <textarea class="form-control" rows="4" placeholder="Количество панелей и Ваше сообщение" id="message" name="message"></textarea>
            </div>
            <button type="submit" id="contact_submit" data-loading-text="•••" class="btn btn-lg btn-block btn-primary"><i class="icon icon-paper-plane"></i>Заказать</button>
       </form>

JS

$(document).ready(function(){
    $("#contactform").submit(function() {
        $.ajax({
            type: "POST",
            url: "/contact.php",
            data: $("#contactform").serialize(),
                success: function() {
                    $('#contact_submit').button('reset');
                    $('#modalContact').modal('hide');
                    //Use modal popups to display messages
                    $('#modalMessage .modal-title').html('<i class="icon icon-envelope-open"></i>Ваше сообщение успешно отправлено!<br>Наш менеджер перезвонит Вам в ближайшее время.<br>Благодарим за заявку!');
                    $('#modalMessage').modal('show');
                },
                error: function() {
                    $('#contact_submit').button('reset');
                    $('#modalContact').modal('hide');
                    //Use modal popups to display messages
                    $('#modalMessage .modal-title').html('<i class="icon icon-ban"></i>Oops!<br>Something went wrong!');
                    $('#modalMessage').modal('show');
                }
        })
        return false;
    });
 });

CONTACT PHP

<?php

$recepient = "**************";
$sitename  = "**************";
$subject   = "New message from \"$sitename\"";

$name = trim($_POST["name"]);
$phone = trim($_POST["phone"]);
$city = trim($_POST["city"]);
$message1 = trim($_POST["message"]);

$message = "
Name: $name <br>
phone: $phone <br>
city: $city <br>
message: $message1
";

mail($recepient, $subject, $message, "From: pinta-acoustic.ru");

?>
Disha V.
  • 1,834
  • 1
  • 13
  • 21
navinweb
  • 3
  • 3
  • Probably comes in your spam box, your email headers are not properly set.. better use something like phpmailer. – Niki van Stein Dec 18 '15 at 08:07
  • 1
    First thing _always_ to do when something "does not work" is to look into your http servers error log file, that is where php typically logs errors to. _Read_ what the error is instead of trying to _guess_ what it might be. Also taking a look at your browsers development console is a valuable source of information, check the network tab in there to see what is actually transferred from client to server. And last not least: when interacting with another server, here a mail server, and you are really stuck, then check that servers log files. – arkascha Dec 18 '15 at 08:10

0 Answers0