L
L
Let_peace2020-08-08 23:25:58
PHP
Let_peace, 2020-08-08 23:25:58

Why does a letter from the server (via php code) either come to my mail or not?

I want to send letters with some text from the server (hosting and domain on reg.ru) to my mail. Code below. The strangest thing is the fact that the letter either comes to the post office or not. I don't understand what it could depend on. If you have any ideas, please tell me.

$message = 'Random Text';
$to = '[email protected]';
$spectext = '<!DOCTYPE HTML><html><head><title>Заказ</title></head><body>';
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";

$mailSent = mail($to, 'Заказ в магазине MementoMori', $spectext.$message.'</body></html>', $headers);

if ($mailSent) {echo 1;} else {echo 0;}

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
Nadim Zakirov, 2020-08-09
@Let_peace

The mail() function is unreliable, since mailers very often ban letters sent from suspicious servers (here questions to the hoster). To guarantee sending notifications, you must use real mail from any major mail service in conjunction with SMTP. Recommend this solution:
https://github.com/Ipatov/SendMailSmtpClass

L
Lev Zabudkin, 2020-08-09
@zabudkin

The script is working.
Mail is sent 100%.
look it up in spam.
well, at
least $spectext.$message
in
htmlentities ($spectext.$message)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question