-1

I have a problem sending an email. After filling out and clicking on the button, it says to me that the letter has been sent, but it does not come to the mail. Please help me solve this problem. Thank you.

js

jQuery(document).ready(function () {
     
  $(".phone").mask("+7 (999) 999-99-99"); 
 

 jQuery('.send-form').click( function() {
   var form = jQuery(this).closest('form');
   
   if ( form.valid() ) {
     form.css('opacity','.5');
     var actUrl = form.attr('action');

     jQuery.ajax({
       url: actUrl,
       type: 'post',
       dataType: 'html',
       data: form.serialize(),
       success: function(data) {
         form.html(data);
         form.css('opacity','1');
       },
       error:    function() {
            form.find('.status').html('Cерверная ошибка');
       }
     });
   }
 });

});

php

<?php
    $name = $_POST['name'];
    $phone = $_POST['phone'];
    $email = $_POST['email'];
    $text = $_POST['text'];

    $to = "tihomirovr764@gmail.com"; 
    $date = date ("d.m.Y"); 
    $time = date ("h:i");
    $from = $email;
    $subject = "Заявка c сайта";

    
    $msg="
    Имя: $name /n
    Телефон: $phone /n
    Почта: $email /n
    Текст: $text";  
    mail($to, $subject, $msg, "From: $from ");

?>

<p>Привет, форма отправлена</p>

<form action="sender.php" method="post" id="form" class="form__body">                       
<div class="form__item">
<input id="formName" type="text" class="dialog-input" name="name" placeholder="Имя" required>
</div>
<div class="form__item">
<div class="dialog-inputs__telefon">                                     
<div class="dialog-inputs__telefon--flag">
<img src="assets/images/Frame 98 (2).svg" alt="">
<img src="assets/images/Frame 99.svg" alt="">
</div>                                                
<input type="text" class="dialog-input" name="phone" placeholder="Телефон">
</div>
</div>                      
<div class="form__item">
<input id="formEmail" type="email" placeholder="E-mail" name="email" class="dialog-input" required>
</div>
<div class="form__item">
<textarea name="text" id="" placeholder="Текст сообщения" class="leave-message__text"></textarea>
</div>                      
<button type="button" class="navbar-nav__button" id="open">Оставить заявку</button>
<div class="status"></div>                          
</form>

I've tried different ways, but none of them worked. I am not very strong in php, I hope for your help.

I want to see the letter

Roman
  • 11
  • 3
  • Please also post your input form code in your question – Ken Lee Aug 31 '23 at 03:39
  • 5
    Your `$from` seems to be just any email address that was filled in. That's not right. It should be an email address from a domain you manage. Email can be difficult if you're unfamiliar with it. See [the first answer here](https://stackoverflow.com/questions/24644436/php-mail-function-doesnt-complete-sending-of-e-mail). What I said is mentioned under the header: _"Don't use a faux From: sender"_, but all the other things mentioned are relevant too. – KIKO Software Aug 31 '23 at 05:26
  • Posted the html form code – Roman Aug 31 '23 at 06:35

0 Answers0