* Adding additional error handling to email message sending.
* Adding additional error handling to email message sending.
* Fixing issue with err being lost in the defer.
* Moving defers to be queued up earlier to ensure they get called.
* Fixed closing encoder to use defer pattern that matches the others.