Replacing mail
is the wrong way to go about solving this problem.
If you need to send mail, but can't invoke the mail
command, then you should use a third-party PHP mailing library that can use other methods. SwiftMailer is frequently recommended. It can use mail
, invoke any sendmail
-compatible binary or use an SMTP server directly. Further, it can be extended to send mail in any other way, thanks to a plugin architecture.
If you find yourself wanting to replace the PHP builtins, chances are that it's your code that is wrong, not PHP. Sure, some of the PHP builtins suck, but replacing the expected behavior of a function with your modified version is going to make future maintainers of your code want to murder you in your sleep.