com.dalsemi.nethack
Class SmtpClient

java.lang.Object
  |
  +--com.dalsemi.nethack.SmtpClient

public class SmtpClient
extends java.lang.Object

Establishes connection with a mail server and sends mail messages using the SMTP Protocol.


Field Summary
protected  java.net.Socket sock
           
 
Constructor Summary
SmtpClient()
          Constructs new SmtpClient to port 25 with system property value of mailhost.
SmtpClient(int port)
          Constructs new SmtpClient with specified port.
SmtpClient(java.lang.String server)
          Constructs new SmtpClient and attaches to specified host.
SmtpClient(java.lang.String server, int port)
          Opens a socket to the specified string and port.
 
Method Summary
 void cc(java.lang.String recipient)
          Parses to line of the message according to RFC specifications
 void closeMessage()
          Send Message and close input/output streams
 void closeServer()
          Close socket and reset all user inputs and outputs
 void from(java.lang.String sender)
          Sends mail server "from:" command with the parameter specified by sender string.
 void openServer(java.lang.String server, int port)
          Opens a socket to the specified server and port number.
 SmtpPrintStream startMessage()
          Send command to mail server to start data segment of the message
 void to(java.lang.String recipient)
          Parses to line of the message according to RFC specifications
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sock

protected java.net.Socket sock
Constructor Detail

SmtpClient

public SmtpClient(java.lang.String server,
                  int port)
           throws java.io.IOException
Opens a socket to the specified string and port.
Parameters:
server - ip number of the mail server
port - port number of the mail server

SmtpClient

public SmtpClient(int port)
           throws java.io.IOException
Constructs new SmtpClient with specified port. Host defaults to system property value of mailhost.
Parameters:
port - port number of the mail server

SmtpClient

public SmtpClient(java.lang.String server)
           throws java.io.IOException
Constructs new SmtpClient and attaches to specified host. Port defaults to 25.
Parameters:
s - ip number of the mail server

SmtpClient

public SmtpClient()
           throws java.io.IOException
Constructs new SmtpClient to port 25 with system property value of mailhost.
Method Detail

closeServer

public void closeServer()
                 throws java.io.IOException
Close socket and reset all user inputs and outputs
Throws:
java.io.IOException -  

openServer

public void openServer(java.lang.String server,
                       int port)
                throws java.io.IOException,
                       java.net.UnknownHostException,
                       com.dalsemi.protocol.mailto.SmtpProtocolException
Opens a socket to the specified server and port number. Method called from constructor
Parameters:
server - ip number of the mail server
port - port number of the mail server
Throws:
java.io.IOException -  
SmtpProtocolException -  
java.net.UnknownHostException -  

from

public void from(java.lang.String sender)
          throws com.dalsemi.protocol.mailto.SmtpProtocolException,
                 java.io.IOException
Sends mail server "from:" command with the parameter specified by sender string.
Parameters:
sender - Sender of the mail message
Throws:
java.io.IOException -  
SmtpProtocolException -  

startMessage

public SmtpPrintStream startMessage()
                             throws com.dalsemi.protocol.mailto.SmtpProtocolException,
                                    java.io.IOException
Send command to mail server to start data segment of the message
Throws:
java.io.IOException -  
SmtpProtocolException -  

cc

public void cc(java.lang.String recipient)
        throws com.dalsemi.protocol.mailto.SmtpProtocolException,
               java.io.IOException
Parses to line of the message according to RFC specifications
Parameters:
To: - of the message
Throws:
java.io.IOException -  
SmtpProtocolException -  

to

public void to(java.lang.String recipient)
        throws com.dalsemi.protocol.mailto.SmtpProtocolException,
               java.io.IOException
Parses to line of the message according to RFC specifications
Parameters:
To: - of the message
Throws:
java.io.IOException -  
SmtpProtocolException -  

closeMessage

public void closeMessage()
                  throws java.io.IOException
Send Message and close input/output streams
Throws:
java.io.IOException -