MailFunctions small refactoring