First, your server needs to be well configured or you will be considered a spammer until you are. This is because of the Sender Policy Framework (SPF) . This should be done at the server level.
There are several places that explain how to send email from various languages, so I'll focus on solving your main problem, not how to do it in the language.
Direct shipping solution from your servers
Configure your server to work to meet the requirements of Sender Policy Framework. This is not trivial, and you will be responsible for seeing SPAM complaints, or even with it configured you may have IP banned.
This solution tends to give more work if the amount of sending emails is huge at the same time.
Shipping solution via paid gateways that guarantees delivery
If you can not configure SPF, a viable option is to contract email gateway services, such as Amazon SES ( Amazon Simple Email Service ) , which releases access data (for example, SMTP data that you could send from anywhere) and will do the service for you.
This solution tends to be simpler than setting up SPF, but it is more expensive. Lets send large numbers of emails with less headache.
Simple and functional solution for few emails
Create a Gmail account, enable SMTP, and configure your framework to send as if it were through this Gmail account. It works great and is the cheapest and easiest way to ensure that your emails will arrive 100% of the time, however it requires you not to send MANY emails at the same time.
If you use Google Apps for Business , the email will be exactly that of the domain of the client, but the free quota nowadays does not allow many different accounts, however it is sufficient for small businesses.