import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
/**
 * Insert the type's description here.
 * Creation date: (1/9/2001 2:08:14 PM)
 * @author: Michael Pell, Solutions Plus, Inc  www.sol-plus.com
 */
public class SendEmail {
		private static final java.lang.String SMTP_HOST = "myhost.com";  //change to your actual host
/**
 * SendEmail constructor comment.
 */
public SendEmail() {
	super();
}
public static void main(String args[]) throws Exception {

	String from = "somename@somedomain.com";  //Change this
	String to = "mjpell@sol-plus.com";  //Change this
	String subject = "Testing email from Java";
	String text = "This email has been sent from a Java application as a test.";

	SendEmailTo(from, to, subject, text);

}
/**
 * Insert the method's description here.
 * Creation date: (11/14/2000 10:29:26 AM)
 * @param host java.lang.String
 * @param to java.lang.String
 * @param subject java.lang.String
 * @param text java.lang.String
 */
public static void SendEmailTo(String to, String subject, String text)
{
	String from = "someOtherEmailName@someDomain.com";  //Change this
	SendEmailTo(from, to, subject, text);
}
/**
 * Insert the method's description here.
 * Creation date: (11/14/2000 10:29:26 AM)
 * @param host java.lang.String
 * @param from java.lang.String
 * @param to java.lang.String
 * @param subject java.lang.String
 * @param text java.lang.String
 */
public static void SendEmailTo(String from, String to, String subject, String text)
{
	try
	{
		// Get system properties
		Properties props = System.getProperties();

		// Setup mail server
		props.put("mail.smtp.host", SMTP_HOST);  //may need to Change this

		// Get session
		Session session = Session.getInstance(props, null);

		// Define message
		MimeMessage message = new MimeMessage(session);
		message.setFrom(new InternetAddress(from));
		message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
		message.setSubject(subject);
		message.setText(text);

		// Send message
		Transport.send(message);
	}
	catch (Exception e)
	{
		System.out.println(e);
	}
}
}
