Some articles suggested to change smtp setting sections to enable mail() function. Here I use MailEnable to achieve a better solution if the smtp server takes authentication phrase.
We still keep smtp=localhost in php.ini. So mail() will send messages to localhost smtp server. We need a relay agent to relay the message to the external sendmail server. MailEnable is a freeware that can be configured to do this.
What I did is to set up smart host, which you can access by MailEnable admin tool-->MailEnable Management --> server-->smtp-->properties.
Click the tab smart host in the form. Give the right smtp server and port . Check 'remote server requires authentication'. Enter your key and pass. Check smart host takes priority. You are all set.
One feature in mailenable is that it can't take angle brakets <> as the from address. It will bracket its own.