download the j2ee.jar from java.sun.com
import javax.mail.*;
import javax.mail.internet.*;
public class MailExample {
public static void main (String args[]) throws Exception {
String host = args[0];
String from = args[1];
String to = args[2];
// Get session
Session session = Session.getInstance(
System.getProperties(), null);
// Define message
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));
message.setSubject("Hello JavaMail");
message.setText("Welcome to JavaMail");
// Define transport
Transport transport = session.getTransport("smtp");
transport.connect(host, "", "");
transport.sendMessage(message, message.getAllRecipients());
transport.close();
}
}