JavaMail API - Environment Setup
To send an e-mail using your Java Application is simple enough but to start with you should have JavaMail API and Java Activation Framework (JAF) installed on your machine.
You will need the JavaBeans Activation Framework (JAF) extension that provides the javax.activation package only when you're not using Java SE 6 or newer.
You can download latest version of JavaMail (Version 1.5.0) from Java's standard website.
You can download latest version of JAF (Version 1.1.1) from Java's standard website.
Download and unzip these files, in the newly created top level directories you will find a number of jar files for both the applications. You need to add mail.jar and activation.jar files in your CLASSPATH.
To send emails, you must have SMTP server that is responsible to send mails. You can use one of the following techniques to get the SMTP server:
Install and use any SMTP server such as Postfix server (for Ubuntu), Apache James server (Java Apache Mail Enterprise Server)etc. (or)
Use the SMTP server provided by the host provider for eg: free SMTP provide by JangoSMTP site is relay.jangosmtp.net (or)
Use the SMTP Server provided by companies e.g. gmail, yahoo, etc.
The examples in the subsequent chapters, we've used the free JangoSMTP server to send email. You can create an account by visiting this site and configure your email adress.