import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
import java.io.*;
public class MailServlet {
public static void main(String args[]) throws Exception {
// if (args.length != 3) {
// System.err.println("Usage: java MailExample host from to");
// System.exit(-1);
//}
String host = "smtp.qut.edu.au";
String from = "arrivals@qut.edu.au";
String to = "arrivals@qut.edu.au";
//String host = args[0];
//String from = args[1];
//String to = args[2];
// Get system properties
MailServlet smtpMailSender = new MailServlet();
Properties props = System.getProperties();
// Setup mail server
props.put("mail.smtp.host", host);
props.put("mail.smtp.auth", "true");
Authenticator auth = new SMTPAuthenticator();
// Get session
Session session = Session.getDefaultInstance(props, null);
session.setDebug(true);
// Define message
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
message.setSubject("The Subject");
message.setText("The Message");
// Send message
Transport.send(message);
}
}
--AnonymousCoward, 30-Aug-2007