Fix service initialization and behaviour when authentication is required

I have tested your pull request applying to the current master.
An exception was thrown using an smtp server that require authentication (gmail).
I have tested successfully the patched code with my company smtp server without authentication and gmail with authentication