I used the code from https://stackoverflow.com/a/2748837 to attempt to log into both Gmail and my website's server, and for both of them I received the same error:
authentication failure [SMTP: Invalid response code received from server (code: 535, response: Incorrect authentication data)]
I have double- and triple-checked that the usernames and passwords are correct (since it works from a desktop client), and removed the brackets around the username. What could be the problem?