1. Run the code with the -w option to make sure the /usr/slib/sendmail actually exists and that you can execute.
2. Also check to make sure you can relay outside of your network. Try sending the mail to an account on the same machine as yourself. If that works, then send it outside your network and see if it reaches there. If not, your mailserver may not allow relaying outside.