Package org.subethamail.smtp
Interface MessageHandler
public interface MessageHandler
The interface that defines the conversational exchange of a single message on
an SMTP connection. Using the term "mail transaction", as defined by RFC
5321, implementing classes of this interface track a single mail transaction.
The methods will be called in the following order:
from()recipient()(possibly more than once)data()done()
- Author:
- Jeff Schnitzer
-
Method Summary
Modifier and TypeMethodDescriptionvoiddata(InputStream data) Called when the DATA part of the SMTP exchange begins.voiddone()Called after all other methods are completed.voidCalled first, after the MAIL FROM during a SMTP exchange.voidCalled once for every RCPT TO during a SMTP exchange.
-
Method Details
-
from
Called first, after the MAIL FROM during a SMTP exchange. A MessageHandler is created after the MAIL command is received, so this function is always called, even if the mail transaction is aborted later.- Parameters:
from- is the sender as specified by the client. It will be a mostly rfc822-compliant email address, already validated by the server. The validation is performed by the JavaMail InternetAddress.parse function, according to the strict rules, which means that "many (but not all) of the RFC822 syntax rules are enforced".- Throws:
RejectException- if the sender should be denied.DropConnectionException- if the connection should be dropped
-
recipient
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
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 droppedTooMuchDataException- if the listener can't handle that much data. An error will be reported to the client.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 mail transaction is aborted at some point after the initial from() call.
-