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.

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.

SMTP server

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 (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.