com.cafesoft.core.smtp
Class SmtpClient

java.lang.Object
  |
  +--com.cafesoft.core.smtp.SmtpClient

public class SmtpClient
extends Object

This class implements a simple SMTP (Simple Mail Transfer Protocol) client. Using a TCP/IP Socket, this class connects to an SMTP server and provides facilities for sending email to the server.


Constructor Summary
SmtpClient(String hostName)
          Create a new SmtpClient for connecting to the specified host.
SmtpClient(String hostName, boolean flag)
          Create a new SmtpClient for connecting to the specified host.
 
Method Summary
 void closeServer()
          Close the connection with the SMTP Server.
 void from(String from)
          Set the message sender.
 PrintStream startMessage()
          Start the body of the email message.
 void to(String to)
          Set the message recipient.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SmtpClient

public SmtpClient(String hostName)
           throws UnknownHostException,
                  IOException
Create a new SmtpClient for connecting to the specified host.

Parameters:
hostName - the name of the SMTP host.

SmtpClient

public SmtpClient(String hostName,
                  boolean flag)
           throws UnknownHostException,
                  IOException
Create a new SmtpClient for connecting to the specified host.

Parameters:
hostName - the name of the SMTP host.
flag - if true, then interactions with the SMTP server are printed to stdout.
Method Detail

from

public void from(String from)
          throws IOException
Set the message sender.

Parameters:
from - the email address of the message sender.
Throws:
IOException - if trouble communicating with the SMTP server.

to

public void to(String to)
        throws IOException,
               UnknownUserException
Set the message recipient.

Parameters:
to - username(s) of the message recipient(s). If more than one recipient at this host, names should be separated by commas and/or spaces.
Throws:
IOException - if trouble communicating with the SMTP server.
UnknownUserException

startMessage

public PrintStream startMessage()
                         throws IOException
Start the body of the email message.

Returns:
the PrintStream to which the message must be written.
Throws:
IOException - if trouble communicating with the SMTP server.

closeServer

public void closeServer()
                 throws IOException
Close the connection with the SMTP Server.

Throws:
IOException - if trouble communicating with the SMTP server.


Generated on 10:40:31 AM September 10, 2003, © 1996-2003 Cafésoft LLC. All rights reserved.