When sending a test email, it was hanging on the authentication method:
Auth method requested: XOAUTH2 Auth methods available on the server: LOGIN,PLAIN,XOAUTH2,PLAIN-CLIENTTOKEN,OAUTHBEARER,XOAUTH
Installing curl resolved it. For Debian and Ubuntu:
apt-get install curl libcurl3 php5-curl