Add retry logic when connecting with mail server.