refactoring EmailSender with thread