Fix unhandled errors in mail.js

fixes #1718

- check for existence of mail before using properties
- return the promise properly
Merge pull request #1719 from ErisDS/fix-1718

Fix unhandled errors in mail.js