This article explains how to use SMTP authentication to send email using the PHP mail() function in PEAR Mail.
How can I send email from a PHP script using SMTP authentication? | MilesWeb
When you use the PHP mail() function, you are sending email directly from your web server instead of your mail server. If you have a mail server through your web host, or even a mail server with another host, it is usually better to send email through that server.
The problem is that the PHP mail() function does not provide a built-in way to send mail via SMTP. If you want to access that functionality, you need to install an additional PHP class.
Here are some options that work: