added html mails and some nil checks