There is an order form that you need to send by mail. Letters come to the mail hosting, and you need what would come on mail.ru. I tried to change the address of the mail and the letters do not come, there is nothing in the spam folders either.

In html hidden inputs:

<input type="hidden" name="project_name" value="3wit.ru"> <input type="hidden" name="admin_email" value="lianaza@mail.ru"> <input type="hidden" name="form_subject" value="Заявка на кровать"> 

code in mail.php:

  $method = $_SERVER['REQUEST_METHOD']; //Script Foreach $c = true; if ( $method === 'POST' ) { $project_name = trim($_POST["project_name"]); $admin_email = trim($_POST["admin_email"]); $form_subject = trim($_POST["form_subject"]); foreach ( $_POST as $key => $value ) { if ( $value != "" && $key != "project_name" && $key != "admin_email" && $key != "form_subject" ) { $message .= " " . ( ($c = !$c) ? '<tr>':'<tr style="background-color: #f8f8f8;">' ) . " <td style='padding: 30px; border: #e9e9e9 1px solid;'><b>$key</b></td> <td style='padding: 30px; border: #e9e9e9 1px solid;'>$value</td> </tr> "; } }} function adopt($text) { return '=?UTF-8?B?'.Base64_encode($text).'?='; } $headers = "MIME-Version: 1.0" . PHP_EOL . "Content-Type: text/html; charset=utf-8" . PHP_EOL . 'From: '.adopt($project_name).' <lianaza@mail.ru>' . PHP_EOL . 'Reply-To: lianaza@mail.ru' . PHP_EOL; mail($admin_email, adopt($form_subject), $message, $headers ); 
  • Show $admin_email how you get $admin_email and other variables for writing - Alex
  • corrected in the code - Liana

1 answer 1

You did not take into account one thing; for a long time everyone has been using SPF, DKIM, DMARC and other checks of the sender’s validity. When you try to send mail to mail.ru, it checks all the headers, and discards your letter, because You have not passed any tests. Therefore, even in the spam folder you did not find your letter! For the test, you can send to any mail server where there are no such checks.

In your case, you need to send letters using SMTP authentication on the server.

  • I understood about it, but I found a review on the forum: For the script to work with mail.ru, change the sender in mail.php. Mail.ru thinks you are writing yourself! For example: 'From:' .adopt ($ project_name). ' <your_text> '. PHP_EOL. 'Reply-To: your_text'. PHP_EOL; - Liana
  • help or gibberish? - Liana
  • @ Liana will not help, in any case there should be a DKIM signature - which you will not have. - Andrey Mihalev
  • Well, thank you, I will study this topic! - Liana
  • since there is no time to study all this, I made a mailing through the hosting mail and comes to Yandex mail duplicate emails) - Liana