WordPress, emails from applications fall into the Spam folder

The site is on WordPress, the hosting and domain of the site are on REG.RU, the domain is Cyrillic. Requests from the feedback form are received, but for some reason they end up in the Spam folder.

I tried sending applications to the mail Mail.ru and Google, both of which were spam. PHP the handler used its own, placed it in the root of the installation WordPress, and provided the code below. I also tried sending via the plugin Contact Form 7, there are also spam emails.

I don't know what to do anymore, please tell me how to solve this problem?

<?php
header("Content-Type: text/html; charset=utf-8");
$name = htmlspecialchars($_POST["name"]);
$tel = htmlspecialchars($_POST["phone"]);
$email = htmlspecialchars($_POST["email"]);
$refferer = getenv('HTTP_REFERER');
$date = date("d.m.y"); // число.месяц.год
$time = date("H:i"); // часы:минуты:секунды
$myemail = "[email protected]";
$tema = "Новый заказ";
$message_to_myemail = "Уважаемый администратор, Вам поступил новый заказ
<br><br>
Имя: $name<br>
Телефон: $tel<br>
Источник (ссылка): $refferer<br>
";


mail( $myemail, $tema, $message_to_myemail, "Reply-To: Davydov-Event 
\r\n"."MIME-Version: 1.0\r\n"."Content-type: text/html; charset=utf-8\r\n" 
);


$tema = "Заказ принят";
$message_to_myemail = "
Спасибо, Ваш заказ успешно принят
";
$myemail = $email;
mail($myemail, $tema, $message_to_myemail, "From: Davydov-Event \r\n Reply- 
To: Davydov-Event \r\n"."MIME-Version: 1.0\r\n"."Content-type: text/html; charset=utf-8\r\n" );
Author: Sergey Konovalenko, 2018-05-23

2 answers

There are several levels of problems here.

Do not use the mail () function - it is deprecated. WordPress has wp_mail () instead.

In order for wp_mail() to work in your handler, you need to initialize the kernel in it:

require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' );

You can use the Contact Form 7 plugin, it works via wp_mail ().

But the main problem is that you must have SPF, DKIM, and DMARC records in your DNS. If they don't exist, everything goes to spam.

In addition, it is better not to send from your server (IP can be blacklisted by spammers), and via relay, from yandex or google SMTP servers.

The WP Mail SMTP plugin from WPForms will help you with this.

 2
Author: KAGG Design, 2018-05-23 07:54:47

Create an email on your hosting, usually hosters provide this opportunity for free.

And write the sender's email instead of Davydov-Event.

You are banned by mail because there is no sender.

 1
Author: md5hash, 2018-05-25 21:08:17