Sending email from php

I am new to this. I am trying to send email using PEAR email package. I am using as the server, and port 587. My script crashes and gives me a message that authentication has failed. I am able to send using my gmail account, but not the DreamHost account. I tried using simple PHP mail(). The message is sent, but it goes directly to my recipient’s spam filter.
Any help would be appreciated.