mail()
uses the smtp/sendmail settings found in php.ini. If you need to send it via another smtp, or one with authentication (like in your example) mail is simply not enough.
There are good mailer libraries out there, just to name a few:
They are all capable of sending emails via an authenticated smtp server.