You probably got this error because the username and password of the from mail id is not matching. Please recheck your password and mail-id (username). It could be a typo.
In some cases, Gmail prevents logging in through external applications or programs which are not authorised. Also login to your gmail account to check if gmail has prevented logging in to your account via your Java Mail API program.
If nothing works, you could try some other SMTP server (like yahoo).
These could be the other problems in your task if you are using Gmail Server.