fluidsharp Posted July 20, 2011 Share Posted July 20, 2011 Hi all, I cannot send mail from one paid hosting, but from another I can (it is some free hosting) How to debug or find out why it doesn't send mails? <?php error_reporting(E_ALL); if (isset($clientName) && isset($clientEmail) && isset($clientMessage)) { $to = "first@mail.ru";//. ", "; //$to .= "second@mail.ru"; $subject = "test mail from site"; $message = $clientMessage; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $l = mail($to, $subject, $message, $headers); if ($l){echo "true";}else echo "false"; echo $l."<h3>Mail was sent</H3>"; print_r(error_get_last()); error_log("error ", 1,"first@mail.ru"); } ?> Thank you in advance! Quote Link to comment https://forums.phpfreaks.com/topic/242448-mail-doesnt-send/ Share on other sites More sharing options...
AyKay47 Posted July 20, 2011 Share Posted July 20, 2011 1. what error(s) are you receiving in you error.log? 2. have you tried a simple test such as mail('email@test.com','test','a test message'); to isolate the SMTP server as the culprit? Quote Link to comment https://forums.phpfreaks.com/topic/242448-mail-doesnt-send/#findComment-1245213 Share on other sites More sharing options...
fluidsharp Posted July 21, 2011 Author Share Posted July 21, 2011 error.log I didn't find. But example from http://php.net/manual/en/function.mail.php (Example #4 Sending HTML email) works. I think if I change $message = $clientMessage; to $message = "Test"; it will work. I will check. PS $clientMessage gets data from POST <textarea>. Quote Link to comment https://forums.phpfreaks.com/topic/242448-mail-doesnt-send/#findComment-1245531 Share on other sites More sharing options...
TeNDoLLA Posted July 21, 2011 Share Posted July 21, 2011 Try adding From: to the headers. Quote Link to comment https://forums.phpfreaks.com/topic/242448-mail-doesnt-send/#findComment-1245534 Share on other sites More sharing options...
AyKay47 Posted July 21, 2011 Share Posted July 21, 2011 Try adding From: to the headers. true, i missed this originally, in order for the mail function to work, a from header must be specified, either in the header parameter or in the php.ini file. Your first step will be to add that to the function Quote Link to comment https://forums.phpfreaks.com/topic/242448-mail-doesnt-send/#findComment-1245824 Share on other sites More sharing options...
fluidsharp Posted July 28, 2011 Author Share Posted July 28, 2011 Try adding From: to the headers. true, i missed this originally, in order for the mail function to work, a from header must be specified, either in the header parameter or in the php.ini file. Your first step will be to add that to the function it helped thanks! but why it works on an another server? Quote Link to comment https://forums.phpfreaks.com/topic/242448-mail-doesnt-send/#findComment-1248422 Share on other sites More sharing options...
AyKay47 Posted July 28, 2011 Share Posted July 28, 2011 most likely the FROM header is specified in the php.ini file on the other server, so it is not needed at runtime Quote Link to comment https://forums.phpfreaks.com/topic/242448-mail-doesnt-send/#findComment-1248501 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.