things.data.transport.smtp
Interface SMTPClient

All Known Implementing Classes:
CleanSMTPClient, FancySMTPClient

public interface SMTPClient

General interface to the SMTP clients.

Version:
1.0

Version History

EPG - Adapted from another project - 23 NOV 06
 
Author:
Erich P. Gatejen

Field Summary
static int ACTION_ABORTED
           
static int ACTION_NOT_TAKEN
           
static int ACTION_OK
           
static int BAD_COMMAND_SEQUENCE
           
static int CODE_211
          SMTP result codes.
static int CODE_214
           
static int CODE_215
           
static int CODE_220
           
static int CODE_221
           
static int CODE_250
           
static int CODE_251
           
static int CODE_354
           
static int CODE_421
           
static int CODE_450
           
static int CODE_451
           
static int CODE_452
           
static int CODE_500
           
static int CODE_501
           
static int CODE_502
           
static int CODE_503
           
static int CODE_504
           
static int CODE_550
           
static int CODE_551
           
static int CODE_552
           
static int CODE_553
           
static int CODE_554
           
static int CODE_FAIL_THRESHOLD
           
static int COMMAND_NOT_IMPLEMENTED
           
static int COMMAND_NOT_IMPLEMENTED_FOR_PARAMETER
           
static int CONNECTION_RETRIES
           
static int CONNECTION_TIMEOUT
           
static int HELP_MESSAGE
           
static int INSUFFICIENT_STORAGE
           
static int MAILBOX_NAME_NOT_ALLOWED
           
static int MAILBOX_UNAVAILABLE
           
static int SERVICE_CLOSING_TRANSMISSION_CHANNEL
           
static int SERVICE_NOT_AVAILABLE
           
static int SERVICE_READY
           
static int START_MAIL_INPUT
           
static int STORAGE_ALLOCATION_EXCEEDED
           
static int SYNTAX_ERROR_IN_ARGUMENTS
           
static int SYSTEM_STATUS
           
static int TRANSACTION_FAILED
           
static int UNRECOGNIZED_COMMAND
           
static int USER_NOT_LOCAL
           
static int USER_NOT_LOCAL_WILL_FORWARD
           
 
Method Summary
 Reply connect(java.lang.String connectAddress, int connectPort)
          Start a connection.
 Reply disconnect()
          Start a connection.
 Reply done()
          Quit the client.
 java.lang.String getName()
          Get client name.
 SMTPState getState()
          Get the state.
 Reply login(java.lang.String hostname)
          HELO with the hostname--no authentication.
 Reply recipient(java.lang.String recipientText)
          Set the recipient using RCPT TO.
 Reply recipient(java.lang.String recipientText, DSN dsn)
          Set the recipient using RCPT TO.
 Reply reset()
          RESET the connection.
 Reply sendData(java.io.InputStream... ios)
          Send DATA.
 Reply sender(java.lang.String senderText)
          Set the sender using MAIL FROM.
 Reply sender(java.lang.String senderText, DSN dsn)
          Set the sender using MAIL FROM.
 void setSocketRetries(int retries)
          Number of times a socket read will be retried after a timeout before completely giving up.
The default value is CONNECTION_RETRIES.
 void setTimeout(int timeout)
          Set the socket timeout for each connection.
 

Field Detail

CONNECTION_TIMEOUT

static final int CONNECTION_TIMEOUT
See Also:
Constant Field Values

CONNECTION_RETRIES

static final int CONNECTION_RETRIES
See Also:
Constant Field Values

CODE_211

static final int CODE_211
SMTP result codes. These will come directly from the server.

See Also:
Constant Field Values

CODE_214

static final int CODE_214
See Also:
Constant Field Values

CODE_215

static final int CODE_215
See Also:
Constant Field Values

CODE_220

static final int CODE_220
See Also:
Constant Field Values

CODE_221

static final int CODE_221
See Also:
Constant Field Values

CODE_250

static final int CODE_250
See Also:
Constant Field Values

CODE_251

static final int CODE_251
See Also:
Constant Field Values

CODE_354

static final int CODE_354
See Also:
Constant Field Values

CODE_421

static final int CODE_421
See Also:
Constant Field Values

CODE_FAIL_THRESHOLD

static final int CODE_FAIL_THRESHOLD
See Also:
Constant Field Values

CODE_450

static final int CODE_450
See Also:
Constant Field Values

CODE_451

static final int CODE_451
See Also:
Constant Field Values

CODE_452

static final int CODE_452
See Also:
Constant Field Values

CODE_500

static final int CODE_500
See Also:
Constant Field Values

CODE_501

static final int CODE_501
See Also:
Constant Field Values

CODE_502

static final int CODE_502
See Also:
Constant Field Values

CODE_503

static final int CODE_503
See Also:
Constant Field Values

CODE_504

static final int CODE_504
See Also:
Constant Field Values

CODE_550

static final int CODE_550
See Also:
Constant Field Values

CODE_551

static final int CODE_551
See Also:
Constant Field Values

CODE_552

static final int CODE_552
See Also:
Constant Field Values

CODE_553

static final int CODE_553
See Also:
Constant Field Values

CODE_554

static final int CODE_554
See Also:
Constant Field Values

SYSTEM_STATUS

static final int SYSTEM_STATUS
See Also:
Constant Field Values

HELP_MESSAGE

static final int HELP_MESSAGE
See Also:
Constant Field Values

SERVICE_READY

static final int SERVICE_READY
See Also:
Constant Field Values

SERVICE_CLOSING_TRANSMISSION_CHANNEL

static final int SERVICE_CLOSING_TRANSMISSION_CHANNEL
See Also:
Constant Field Values

ACTION_OK

static final int ACTION_OK
See Also:
Constant Field Values

USER_NOT_LOCAL_WILL_FORWARD

static final int USER_NOT_LOCAL_WILL_FORWARD
See Also:
Constant Field Values

START_MAIL_INPUT

static final int START_MAIL_INPUT
See Also:
Constant Field Values

SERVICE_NOT_AVAILABLE

static final int SERVICE_NOT_AVAILABLE
See Also:
Constant Field Values

ACTION_NOT_TAKEN

static final int ACTION_NOT_TAKEN
See Also:
Constant Field Values

ACTION_ABORTED

static final int ACTION_ABORTED
See Also:
Constant Field Values

INSUFFICIENT_STORAGE

static final int INSUFFICIENT_STORAGE
See Also:
Constant Field Values

UNRECOGNIZED_COMMAND

static final int UNRECOGNIZED_COMMAND
See Also:
Constant Field Values

SYNTAX_ERROR_IN_ARGUMENTS

static final int SYNTAX_ERROR_IN_ARGUMENTS
See Also:
Constant Field Values

COMMAND_NOT_IMPLEMENTED

static final int COMMAND_NOT_IMPLEMENTED
See Also:
Constant Field Values

BAD_COMMAND_SEQUENCE

static final int BAD_COMMAND_SEQUENCE
See Also:
Constant Field Values

COMMAND_NOT_IMPLEMENTED_FOR_PARAMETER

static final int COMMAND_NOT_IMPLEMENTED_FOR_PARAMETER
See Also:
Constant Field Values

MAILBOX_UNAVAILABLE

static final int MAILBOX_UNAVAILABLE
See Also:
Constant Field Values

USER_NOT_LOCAL

static final int USER_NOT_LOCAL
See Also:
Constant Field Values

STORAGE_ALLOCATION_EXCEEDED

static final int STORAGE_ALLOCATION_EXCEEDED
See Also:
Constant Field Values

MAILBOX_NAME_NOT_ALLOWED

static final int MAILBOX_NAME_NOT_ALLOWED
See Also:
Constant Field Values

TRANSACTION_FAILED

static final int TRANSACTION_FAILED
See Also:
Constant Field Values
Method Detail

getName

java.lang.String getName()
Get client name.

Returns:
the clients name.

getState

SMTPState getState()
Get the state.

Returns:
State

setTimeout

void setTimeout(int timeout)
Set the socket timeout for each connection. A timeout may be retried, depending on the value set with setSocketRetries(int).
The default value is CONNECTION_TIMEOUT.

It will take effect whenever a new connection is established.

Parameters:
timeout - the timeout in milliseconds.

setSocketRetries

void setSocketRetries(int retries)
Number of times a socket read will be retried after a timeout before completely giving up.
The default value is CONNECTION_RETRIES.

It will take effect whenever a new operation is started.

Parameters:
retries - Number of retries. Zero or a negative number is the same as no retries.

connect

Reply connect(java.lang.String connectAddress,
              int connectPort)
              throws ThingsException,
                     java.lang.InterruptedException
Start a connection. Return a code. It will throw an ERROR is already connect, but will leave the connection intact.

Parameters:
connectAddress -
connectPort -
Returns:
ACTION_OK if it was ok.
Throws:
ThingsException - will always be fatal at this point.
java.lang.InterruptedException

disconnect

Reply disconnect()
                 throws ThingsException,
                        java.lang.InterruptedException
Start a connection. Return a code.

Returns:
The reply.
Throws:
ThingsException - which will never happen, since we'll just abandon the bad connection.
java.lang.InterruptedException

login

Reply login(java.lang.String hostname)
            throws ThingsException,
                   java.lang.InterruptedException
HELO with the hostname--no authentication. A state problem will cause a FAULT. A transmission problem is just an ERROR. It will transition to LOGIN_COMPLETE only of the reply is an ACTION_OK.

Parameters:
hostname -
Returns:
the reply.
Throws:
ThingsException
java.lang.InterruptedException

sender

Reply sender(java.lang.String senderText)
             throws ThingsException,
                    java.lang.InterruptedException
Set the sender using MAIL FROM. It must be at LOGIN_COMPLETE.

Parameters:
senderText - as a valid SMTP address.
Returns:
A reply.
Throws:
ThingsException - if not ready for MAIL FROM or actual transmission problem.
java.lang.InterruptedException

sender

Reply sender(java.lang.String senderText,
             DSN dsn)
             throws ThingsException,
                    java.lang.InterruptedException
Set the sender using MAIL FROM. It must be at LOGIN_COMPLETE. Implementation of the DSN is up to the client. It may choose to ignore it.

Parameters:
senderText - as a valid SMTP address.
dsn - command. If null, it will be ignored.
Returns:
A reply.
Throws:
ThingsException - if not ready for MAIL FROM or actual transmission problem.
java.lang.InterruptedException

recipient

Reply recipient(java.lang.String recipientText)
                throws ThingsException,
                       java.lang.InterruptedException
Set the recipient using RCPT TO. It must be at MAILFROM_DONE.

Parameters:
recipientText - as a valid SMTP address.
Returns:
A reply.
Throws:
ThingsException - if not ready for RCPT TO or actual transmission problem.
java.lang.InterruptedException

recipient

Reply recipient(java.lang.String recipientText,
                DSN dsn)
                throws ThingsException,
                       java.lang.InterruptedException
Set the recipient using RCPT TO. It must be at MAILFROM_DONE. Implementation of the DSN is up to the client. It may choose to ignore it.

Parameters:
recipientText - as a valid SMTP address.
dsn - command. If null, it will be ignored.
Returns:
A reply.
Throws:
ThingsException - if not ready for RCPT TO or actual transmission problem.
java.lang.InterruptedException

reset

Reply reset()
            throws ThingsException,
                   java.lang.InterruptedException
RESET the connection. This will return the state to LOGIN_COMPLETE, as long as it has already been logged in.

Returns:
the reply.
Throws:
ThingsException - if the connection is made and logged in.
java.lang.InterruptedException

sendData

Reply sendData(java.io.InputStream... ios)
               throws ThingsException,
                      java.lang.InterruptedException
Send DATA. It must be at RCPTTO_DONE. It will do the appropriate dot doubling and CRLF management.

Parameters:
ios - Stream to send. You handle any buffering. Null entries are allowed and ignored.
Returns:
the reply
Throws:
ThingsException
java.lang.InterruptedException

done

Reply done()
           throws ThingsException,
                  java.lang.InterruptedException
Quit the client. This will return it to FRESH. It will never throw an exception, but may return a bad reply.

Returns:
a reply
Throws:
ThingsException
java.lang.InterruptedException


Things.