see https://security.googleblog.com/2014/04/new-security-measures-will-affect-older.html for details. so this code doesn't work with smtp.gmail.com anymore, not even over SSL.