mail() has stopped working under php as of June 24, 2019 - trying to troubleshoot

Avatar
  • updated
  • Answered
Pinned replies
Avatar
WestLA_user
  • Answer

Contacted Live Support just after posting. I'm posting a follow-up in case anyone has the same problem.

There were two problems - one support could fix and one they could not but I could.


1. My PHP config got messed up. Don't know how but the location of "sendmail" got deleted from my config within the last couple of weeks. Support deleted the "php.ini" file under my "public_html" directory and then did something with CPanel to create a new one (which was 15-20 times as large). My script then ran fine from a browser but not from cron. Support informed me (erroneously) that sendmail was disabled for shared accounts. Obviously not true since I could run my script from the browser. However, I thought it might be true when running from cron. Support suggested using phpmailer instead to get around the problem. End of support call.

2. I then did a bit of research on my own and changed the cron job description and got it to work from cron. So, no need to use phpmailer (which I've used elsewhere in the past and prefer to avoid if I can as it is a bit convoluted to use, though it did work for me elsewhere in the past when set up correctly).

Did not work: 0 * * * * php /home/<username>/public_html/script.php

Did work: 0 * * * * /usr/local/bin/php /home/<username>/public_html/script.php

Not sure why but the requirements for pointing to php in cron keep changing. I used the full path initially but then a while ago that stopped working so I had to put in just "php" to get it to work. Now, I've had to change back to the full path again. Very confusing when I didn't do anything different. I've seen instructions on the internet to put "root" as user before "php" to solve "script won't run" problems but I haven't had to do that to get scripts to run under cron for me so don't know if that is possible or will solve problems.

My problem solved through a combination of support help and some good old-fashioned research using Google.

Avatar
WestLA_user
  • Answer

Contacted Live Support just after posting. I'm posting a follow-up in case anyone has the same problem.

There were two problems - one support could fix and one they could not but I could.


1. My PHP config got messed up. Don't know how but the location of "sendmail" got deleted from my config within the last couple of weeks. Support deleted the "php.ini" file under my "public_html" directory and then did something with CPanel to create a new one (which was 15-20 times as large). My script then ran fine from a browser but not from cron. Support informed me (erroneously) that sendmail was disabled for shared accounts. Obviously not true since I could run my script from the browser. However, I thought it might be true when running from cron. Support suggested using phpmailer instead to get around the problem. End of support call.

2. I then did a bit of research on my own and changed the cron job description and got it to work from cron. So, no need to use phpmailer (which I've used elsewhere in the past and prefer to avoid if I can as it is a bit convoluted to use, though it did work for me elsewhere in the past when set up correctly).

Did not work: 0 * * * * php /home/<username>/public_html/script.php

Did work: 0 * * * * /usr/local/bin/php /home/<username>/public_html/script.php

Not sure why but the requirements for pointing to php in cron keep changing. I used the full path initially but then a while ago that stopped working so I had to put in just "php" to get it to work. Now, I've had to change back to the full path again. Very confusing when I didn't do anything different. I've seen instructions on the internet to put "root" as user before "php" to solve "script won't run" problems but I haven't had to do that to get scripts to run under cron for me so don't know if that is possible or will solve problems.

My problem solved through a combination of support help and some good old-fashioned research using Google.

Avatar
anonymous
  • Answered
I recommend you check your PHP logs, phpinfo page, PHP.ini settings for troubleshooting. We'd be happy to assist you further if you provide more info regarding the issue with Live Support.
Avatar
anonymous
  • Under review