V
V
Vitaly Balayan2018-07-16 12:38:54
Data processing
Vitaly Balayan, 2018-07-16 12:38:54

PHP not sending form data to email?

The essence of the question is in the title.
HTML

<form id="callphone" class="callphone">
  <input type="phone" name="phone" id="phone" placeholder="+7 (775) 225-33-44" required>
  <button type="submit" class="button">Отправить</button>
  <p class="enterinfo">*Введите номер телефона</p>
</form>

JS
$(document).ready(function() {

  $("#callphone").submit(function() {
    $.ajax({
      type: "POST",
      url: "mail.php",
      data: $(this).serialize()
    }).done(function() {
      $(this).find("input").val("");
      alert("Спасибо за заявку! Скоро мы с вами свяжемся.");
      $("#callphone").trigger("reset");
    });
    return false;
  });
  
});

PHP
<?php

$recepient = "[email protected]";
$sitename = "ТОО Информационно-Технологический Сервис";

$phone = trim($_POST["phone"]);
$message = "Телефон: $phone";

$pagetitle = "Новая заявка с сайта \"$sitename\"";
mail($recepient, $pagetitle, $message, "Content-type: text/plain; charset=\"utf-8\"\n From: $recepient");

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Dart, 2018-07-16
@gobananas

In most cases such problem is related to the mail() function use PHPMailer or SwiftMailer

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question