How to fix PHP application stopped sending emails via sendmail

TL;DR

check /usr/sbin using via ssh or filezilla or putty or whatever you use if it has a file named sendmail on it.
if it has sendmail.postfix on it you need to change the sendmail path on php.ini file on your cyberpanel
login to cyberpanel via the port you use ->php->edit php config → click and advanced and select the php version you are using for the application then find this line
sendmail_path = /usr/sbin/sendmail -t -i
change it to
sendmail_path = /usr/sbin/sendmail.postfix -t -i

This is more of tip for everyone. we recently moved from our old hosting provider to a new one.
we have successfully moved everything and almost everything was fine except for one thing our applications are not sending emails.
we spent about a week troubleshooting and even contemplating if the move to our new hosting provider was a bad idea. logs did not help that much so resulted to rewriting some parts and components that we use to use smtp instead of sendmail … fast forward a couple of days later by mistake across the urs/sbin directory and realize oh sendmail with postfix here is a bit different.
this solution can also help those with wordpress installs not sending emails.

hope it helps guys .

3 days trying to solve this problem and thanks to you I fixed it.

Thanks a lot !!!

1 Like

Hello, I’m beating my head on this one, trying to send emails using PHP.

It seems that mb_send_mail() just like mail() function sends them as [usernXXXX]@[domain.ext] even though I pass the correct parameters to it.

I can’t figure out where to change this as it gets all my emails rejected on external servers due to the email not existing on the server.

I’ve tried the solution above with my sendmail path (it was commented out in my php version !?):
sendmail_path = /usr/sbin/sendmail -t -i

However it still does the same thing.
Apart from actually creating the linux user for each domain as email account which would obviously pose a security risk, is there a way to fix the issue using a default email account for the server that would be ok to use?