org.subethamail.smtp
Interface MessageHandler


public interface MessageHandler

The interface that defines the conversational exchange of a single message on an SMTP connection. The methods will be called in the following order:

  1. from()
  2. recipient() (possibly more than once)
  3. data()
If multiple messages are delivered on a single connection (ie, using the RSET command) then multiple message handlers will be instantiated. Each handler services one and only one message.

Author:
Jeff Schnitzer

Method Summary
 void data(java.io.InputStream data)
          Called when the DATA part of the SMTP exchange begins.
 void done()
          Called after all other methods are completed.
 void from(java.lang.String from)
          Called first, after the MAIL FROM during a SMTP exchange.
 void recipient(java.lang.String recipient)
          Called once for every RCPT TO during a SMTP exchange.
 

Method Detail

from

void from(java.lang.String from)
          throws RejectException
Called first, after the MAIL FROM during a SMTP exchange.

Parameters:
from - is the sender as specified by the client. It will be a rfc822-compliant email address, already validated by the server.
Throws:
RejectException - if the sender should be denied.
DropConnectionException - if the connection should be dropped

recipient

void recipient(java.lang.String recipient)
               throws RejectException
Called once for every RCPT TO during a SMTP exchange. This will occur after a from() call.

Parameters:
recipient - is a rfc822-compliant email address, validated by the server.
Throws:
RejectException - if the recipient should be denied.
DropConnectionException - if the connection should be dropped

data

void data(java.io.InputStream data)
          throws RejectException,
                 TooMuchDataException,
                 java.io.IOException
Called when the DATA part of the SMTP exchange begins. This will occur after all recipient() calls are complete. Note: If you do not read all the data, it will be read for you after this method completes.

Parameters:
data - will be the smtp data stream, stripped of any extra '.' chars. The data stream will be valid only for the duration of the call.
Throws:
RejectException - if at any point the data should be rejected.
DropConnectionException - if the connection should be dropped
TooMuchDataException - if the listener can't handle that much data. An error will be reported to the client.
java.io.IOException - if there is an IO error reading the input data.

done

void done()
Called after all other methods are completed. Note that this method will be called even if the client never triggered any of the other callbacks.



Copyright © 2006-2011. All Rights Reserved.