the php mail function will only work with an SMTP server that does not require username and password authentication.
There are many SMTP servers available that do not require authentication.
The SMTP server from many hosting companies are set to allow emails to be relayed with out authentication as long as the from address is one that belongs to the hosted domain.