check this tutorial:Fundamentals of the JavaMail API
]All about JavaMail
pretty good, it's all in there.
A web email account like gmail will not work for development, as they let you demand access on a limited base and will ban you when you fail with your login.
If you need a email server try HMail Server: http://www.hmailserver.com/
] (auto-ban option to be switched off in settings!)