F
F
Foot2020-09-28 18:16:04
PHP
Foot, 2020-09-28 18:16:04

Sending emails with PHP?

Not receiving emails. I currently use free hosting qlihost.ru. A success message appears, but there is no email.

There is a form:

<form id="form" class="form-signin p-4 mt-4" action="" method="post">
      <div class="row">
      <div class="col-sm">
        <input type="text" name="your_name" id="inputName" class="form-control" placeholder="Ваше имя*" required="">
          <br>
        <input type="email" name="your_mail" id="inputEmail" class="form-control" placeholder="Ваш E-mail">
        <br>
        <input type="tel" name="your_phone" id="inputPassword" class="form-control mb-4" placeholder="Номер телефона*" required="">
      </div>
      <div class="col-sm">
        <textarea name="your_message" class="form-control" placeholder="Ваше сообщение" style="height: 92px;"></textarea>
        <br>
        <input type="submit" name="send" value="Получить консультацию" class="btn btn-block bg-autumn text-white in_banner">
      </div>
      </div>
      <span class="text-muted">Вы соглашаетесь с условиями обработки персональных данных. <a href="#" class="texe-inform">Ознакомиться</a>.</span>
    </form>


And PHP script:
<? $name=$_POST['your_name'];
$mail=$_POST['your_mail'];
$phone=$_POST['your_phone'];
$message=$_POST['your_message'];
$send=$_POST['send'];
$my_mail='[email protected]';
if(isset($send)){
  if($send=='Получить консультацию'){
    if(!empty($name) && !empty($phone)){
      mail($my_mail, $phone, $message.' ('.$mail.')');
      echo "Спасибо за Ваше сообщение, оно успешно отправлено.";
    }
  }
} ?>


I especially want to know what exactly you need to look at in the logs, if they matter here. Thank you in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
ThunderCat, 2020-09-28
@ulechkafox

Success message appears
It is tied to the presence of fields, and not to sending a letter.
I especially want to know what exactly you need to look at in the logs, if they matter here. Thank you in advance.

1) mail() has a bunch of restrictions, especially on free hosting
2) mail() is not required to send a letter, its task is to give it to the server specified in the php smtp config, what will happen to him next is absolutely violet.
3) It would be nice to at least check what mail() returned
4) A good solution would be to use normal libraries for sending mail, PHPMailrer, SwiftMailer...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question