You will need to test the script out on a server with an SMTP server running. To do local email testing like this on a Windows machine I will make use of a nice tool called Free SMTP Server. It is very simple to use and acts as a local SMTP server. I can use this tool on my Windows machine to successfully send emails. I'm not sure of any for the Mac though. If you have access to a live server for testing purposes that has an SMTP server you should be able to use that.