CONGO AppServer

Class Smtp

java.lang.Object
  extended bySmtp

public class Smtp
extends java.lang.Object

The Simple Mail Transfer Protocol class. This class was borrowed for the GJT, and scaled to do just what we require.

Version:
$Id: Smtp.java,v 1.1 2002/03/22 21:53:17 shevett Exp $
Author:
$Author: shevett $

Field Summary
static java.lang.String REVISION
          The current CVS revision of this class
 
Constructor Summary
Smtp(java.lang.String server)
          Connects to the specified SMTP server, on the default (and standard) port 25.
Smtp(java.lang.String server, int port)
          Connects to the specified SMTP server on a given port
 
Method Summary
 void close()
          Closes down the connection to the server
 java.io.PrintWriter getOutputStream()
          Gets the PrintWriter allowing data to be sent directly to the SMTP server
 void sendCommand(java.lang.String cmd, int reply)
          Sends a command to the server
 void sendMessage()
          Completes and sends the current message
 void setSender(java.lang.String sender)
          Specify who the message is from
 void setTo(java.lang.String to)
          Specify who the message is to be sent to
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REVISION

public static final java.lang.String REVISION
The current CVS revision of this class

See Also:
Constant Field Values
Constructor Detail

Smtp

public Smtp(java.lang.String server)
     throws java.io.IOException
Connects to the specified SMTP server, on the default (and standard) port 25.

Parameters:
server - The SMTP server to use
Throws:
java.io.IOException - if the connection to the server fails

Smtp

public Smtp(java.lang.String server,
            int port)
     throws java.io.IOException
Connects to the specified SMTP server on a given port

Parameters:
server - The SMTP server to use
port - The SMTP server port
Throws:
java.io.IOException - if the connection to the server fails
Method Detail

close

public void close()
           throws java.io.IOException
Closes down the connection to the server

Throws:
java.io.IOException - if the command fails

setSender

public void setSender(java.lang.String sender)
               throws java.io.IOException
Specify who the message is from

Parameters:
sender - the e-mail address of the sender
Throws:
java.io.IOException - if the command fails

setTo

public void setTo(java.lang.String to)
           throws java.io.IOException
Specify who the message is to be sent to

Parameters:
to - the e-mail address of the receiver
Throws:
java.io.IOException - if the command fails

getOutputStream

public java.io.PrintWriter getOutputStream()
                                    throws java.io.IOException
Gets the PrintWriter allowing data to be sent directly to the SMTP server

Returns:
a reference to the PrintWriter
Throws:
java.io.IOException - if the command fails

sendMessage

public void sendMessage()
                 throws java.io.IOException
Completes and sends the current message

Throws:
java.io.IOException - if the command fails

sendCommand

public void sendCommand(java.lang.String cmd,
                        int reply)
                 throws java.io.IOException
Sends a command to the server

Parameters:
cmd - The command to send
reply - The expected reply-code
Throws:
java.io.IOException - if the incorrect response code is received

CONGO AppServer

Copyright © 2004 Stonekeep Consulting, Inc.