Hello friends! There is a question, did sending letters using php. On Denver works well, letters come. Tested on jino hosting first worked then the error came out. After about 30 minutes - 1 hour, the letters worked normally again, and that's how it was constantly. I will send a few letters then an error, it will take time and work again. What is the problem? Here is the actual code itself:

$stext = "Текст"; $subject = "Тех поддержка"; $headers = "From: ".$adminmail."\n"; $headers .= "Reply-to: ".$adminmail."\n"; $headers .= "X-Sender: < http://".$cfgURL." >\n"; $headers .= "Content-Type: text/html; charset=windows 1251\n"; $send = mail($adminmail,$subject,$stext,$headers); if(!$send) { print "Ошибка почтового сервера! Приносим извинения за предоставленные неудобства"; } else { print "Сообщение отправлено"; } 

Can make sending with smtp? What do you advise. And yet, the mail $ adminmail put and Yandex and gmail, and even hosting.

    2 answers 2

    If the mail goes away intermittently, most likely the problem is the server itself. Best on this issue to contact those. support your host.

    • Posted, waiting for an answer. So this is not a problem code? Can do with smtp? - Vyacheslav
    • There are no problems in the code if PHP itself did not tell you about it. Why does your mail go away as you like? Nobody knows better than your support. - Adobe
    • Thank you) wait for an answer. - Vyacheslav
    • Now generally stopped sending. What happens does not understand - Vyacheslav
    • If $ send returns true, then exactly to the hoster. - Adobe

    Personally, I would advise you to do it through smtp. I used to do it myself, but then letters began to get into spam, or not to come at all. Found a wonderful library: https://github.com/PHPMailer/PHPMailer Connecting is very simple. Try, you will not regret ... If anything, ask ...

    • Thank you very much) I'm not special in php and only by examples I can understand something) okay, I read. By the way, thanks to all, I wrote to the hosting support service and it really didn’t happen due to a failure. Now corrected and letters come in just a second. Of course smtp will be better, I will try to figure it out) Thanks again to everyone. By the way, if anyone understands well in php and ajax, see my post ru.stackoverflow.com/questions/422761/… - Vyacheslav