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

Add new attachment

In order to upload a new attachment to this page, please use the following box to find the file, then click on “Upload”.
« This page (revision-10) was last changed on 30-Aug-2007 11:24 by AnonymousCoward