I don't know how well this would mesh with what your book wants to do, but I prefer to use PHPMailer for dealing with this, making use of its included SMTP class. This way with just a couple lines of code I can have it send via my internet mail account when testing on my local PC, then easily change it to use the production server's sendmail function when going live (if that's what I want to do).