Refactoring and fix plaintext mails