About Me

My Photo
I am a Software Architect and Developer based in Bangalore, India. I have experience in building (scalable) applications using Java, JSP, JSF, JBoss Drools, Spring Framework, Hibernate, Ajax, JavaScript, MySQL, NoSQL (HBase, Project Voldemort). I am also a fan of Ruby on Rails, and have done some experimental work with it.

Saturday, July 17, 2010

Sending emails using gmail SMTP Server (in Java)

After doing a bit of search on google, I found here a code snippet in the comments section that can be used to send emails through gmail.  There was a minor typo in the code snippet in the "main" function, where class name was wrongly spelt as "MailUtils" instead of "SimpleMail".

This code depends on Java Mail API.  I picked the "mail.jar" from Spring distribution's "lib" directory.

Thats it!  I was sending emails from Java in no time.

Code sample is available as my github GIST here. http://gist.github.com/479631

No comments: