import Java.io.*;
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
public class SmtpMail
{
public static void main(String args[]) throws Exception
{
// create some properties and get the default Session
Properties props = new Properties();
props.put("mail.smtp.host", "yoursmtpserver");
Session session = Session.getDefaultInstance(props, null);
Message message = new MimeMessage(session);
// create a message
InternetAddress ia[] = new InternetAddress[1];
ia[0] = new InternetAddress("myself@abc.com", "Me");
message.setFrom(new InternetAddress("test@abc.com", "some developer"));
message.setRecipients(Message.RecipientType.TO, ia);
message.setSubject("Hello World");
message.setText("Hello World! This message was generated using JavaMail.");
message.saveChanges();
Transport transport = session.getTransport("smtp");
transport.connect();
transport.send(message);
}
}