extract imap and smtp functions in dedicated classes
big refactoring