Fix unhandled errors in mail.js

fixes #1718

- check for existence of mail before using properties
- return the promise properly