If you want to connect to your Gmail account while 2-step authentication is active, a special password must be generated for the host software. To generate a password go to the Application-specific passwords page.

Initially this had me thinking there was a bug and a connection wasn't possible but I realized after a few minutes that the 2-step auth might be the cause of not being able to connect. I hope this will be useful for others encountering a similar issue.

Maybe it would be a good idea to put a notification somewhere if the user tries to connect to Gmail and the connection fails when testing the connection.