moving all mail related code to MailClient.