|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgnu.inet.smtp.SMTPConnection
public class SMTPConnection
An SMTP client. This implements RFC 2821.
Field Summary | |
---|---|
protected static int |
AMBIGUOUS
|
protected static java.lang.String |
AUTH
|
protected boolean |
continuation
If true, there are more responses to read. |
protected static java.lang.String |
DATA
|
static int |
DEFAULT_PORT
The default SMTP port. |
protected static java.lang.String |
EHLO
|
protected static java.lang.String |
EXPN
|
protected static java.lang.String |
FINISH_DATA
|
protected java.lang.String |
greeting
The greeting message given by the server. |
protected static java.lang.String |
HELO
|
protected static java.lang.String |
HELP
|
protected LineInputStream |
in
The input stream used to read responses from the server. |
protected static int |
INFO
|
static java.util.logging.Logger |
logger
The logger used for SMTP protocol traces. |
protected static java.lang.String |
MAIL_FROM
|
protected static java.lang.String |
NOOP
|
protected static int |
OK
|
protected static int |
OK_NOT_LOCAL
|
protected static int |
OK_UNVERIFIED
|
protected CRLFOutputStream |
out
The output stream used to send commands to the server. |
protected static java.lang.String |
QUIT
|
protected static java.lang.String |
RCPT_TO
|
protected static int |
READY
|
protected java.lang.String |
response
The last response message received from the server. |
protected static java.lang.String |
RSET
|
protected static int |
SEND_DATA
|
static java.util.logging.Level |
SMTP_TRACE
The network trace level. |
protected java.net.Socket |
socket
The underlying socket used for communicating with the server. |
protected static java.lang.String |
SP
|
protected static java.lang.String |
STARTTLS
|
protected static java.lang.String |
VRFY
|
Constructor Summary | |
---|---|
SMTPConnection(java.lang.String host)
Creates a new connection to the specified host, using the default SMTP port. |
|
SMTPConnection(java.lang.String host,
int port)
Creates a new connection to the specified host, using the specified port. |
|
SMTPConnection(java.lang.String host,
int port,
int connectionTimeout,
int timeout)
Creates a new connection to the specified host, using the specified port. |
|
SMTPConnection(java.lang.String host,
int port,
int connectionTimeout,
int timeout,
boolean secure,
javax.net.ssl.TrustManager tm)
Creates a new connection to the specified host, using the specified port. |
Method Summary | |
---|---|
boolean |
authenticate(java.lang.String mechanism,
java.lang.String username,
java.lang.String password)
Authenticates the connection using the specified SASL mechanism, username, and password. |
java.io.OutputStream |
data()
Requests an output stream to write message data to. |
java.util.List |
ehlo(java.lang.String hostname)
Issues an EHLO command. |
java.util.List |
expn(java.lang.String address)
Returns a list of valid possibilities for the specified mailing list, or null on failure. |
boolean |
finishData()
Completes the DATA procedure. |
protected int |
getAllResponses()
Returns the next response from the server. |
java.lang.String |
getGreeting()
Returns the server greeting message. |
java.lang.String |
getLastResponse()
Returns the text of the last response received from the server. |
protected int |
getResponse()
Returns the next response from the server. |
protected javax.net.ssl.SSLSocketFactory |
getSSLSocketFactory(javax.net.ssl.TrustManager tm)
Returns a configured SSLSocketFactory to use in creating new SSL sockets. |
boolean |
helo(java.lang.String hostname)
Issues a HELO command. |
java.util.List |
help(java.lang.String arg)
Returns some useful information about the specified parameter. |
boolean |
mailFrom(java.lang.String reversePath,
ParameterList parameters)
Execute a MAIL command. |
void |
noop()
Issues a NOOP command. |
void |
quit()
Close the connection to the server. |
boolean |
rcptTo(java.lang.String forwardPath,
ParameterList parameters)
Execute a RCPT command. |
void |
rset()
Aborts the current mail transaction. |
protected void |
send(java.lang.String command)
Send the specified command string to the server. |
boolean |
starttls()
Negotiate TLS over the current connection. |
boolean |
starttls(javax.net.ssl.TrustManager tm)
Negotiate TLS over the current connection. |
java.util.List |
vrfy(java.lang.String address)
Returns a list of valid possibilities for the specified address, or null on failure. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.util.logging.Logger logger
public static final java.util.logging.Level SMTP_TRACE
public static final int DEFAULT_PORT
protected static final java.lang.String MAIL_FROM
protected static final java.lang.String RCPT_TO
protected static final java.lang.String SP
protected static final java.lang.String DATA
protected static final java.lang.String FINISH_DATA
protected static final java.lang.String RSET
protected static final java.lang.String VRFY
protected static final java.lang.String EXPN
protected static final java.lang.String HELP
protected static final java.lang.String NOOP
protected static final java.lang.String QUIT
protected static final java.lang.String HELO
protected static final java.lang.String EHLO
protected static final java.lang.String AUTH
protected static final java.lang.String STARTTLS
protected static final int INFO
protected static final int READY
protected static final int OK
protected static final int OK_NOT_LOCAL
protected static final int OK_UNVERIFIED
protected static final int SEND_DATA
protected static final int AMBIGUOUS
protected java.net.Socket socket
protected LineInputStream in
protected CRLFOutputStream out
protected java.lang.String response
protected boolean continuation
protected final java.lang.String greeting
Constructor Detail |
---|
public SMTPConnection(java.lang.String host) throws java.io.IOException
host
- the server hostname
java.io.IOException
public SMTPConnection(java.lang.String host, int port) throws java.io.IOException
host
- the server hostnameport
- the port to connect to
java.io.IOException
public SMTPConnection(java.lang.String host, int port, int connectionTimeout, int timeout) throws java.io.IOException
host
- the server hostnameport
- the port to connect toconnectionTimeout
- the connection timeout in millisecondstimeout
- the I/O timeout in milliseconds
java.io.IOException
public SMTPConnection(java.lang.String host, int port, int connectionTimeout, int timeout, boolean secure, javax.net.ssl.TrustManager tm) throws java.io.IOException
host
- the server hostnameport
- the port to connect toconnectionTimeout
- the connection timeout in millisecondstimeout
- the I/O timeout in millisecondssecure
- true to create an SMTPS connectiontm
- a trust manager used to check SSL certificates, or null to
use the default
java.io.IOException
Method Detail |
---|
public java.lang.String getGreeting()
public java.lang.String getLastResponse()
public boolean mailFrom(java.lang.String reversePath, ParameterList parameters) throws java.io.IOException
reversePath
- the source mailbox(from address)parameters
- optional ESMTP parameters
java.io.IOException
public boolean rcptTo(java.lang.String forwardPath, ParameterList parameters) throws java.io.IOException
forwardPath
- the forward-path(recipient address)parameters
- optional ESMTP parameters
java.io.IOException
public java.io.OutputStream data() throws java.io.IOException
flush
method must be called on the stream. Until then no
further methods should be called on the connection.
Immediately after this procedure is complete, finishData
must be called to complete the transfer and determine its success.
java.io.IOException
public boolean finishData() throws java.io.IOException
java.io.IOException
data()
public void rset() throws java.io.IOException
java.io.IOException
public java.util.List vrfy(java.lang.String address) throws java.io.IOException
address
- a mailbox, or real name and mailbox
java.io.IOException
public java.util.List expn(java.lang.String address) throws java.io.IOException
address
- a mailing list name
java.io.IOException
public java.util.List help(java.lang.String arg) throws java.io.IOException
arg
- the context of the query, or null for general information
java.io.IOException
public void noop() throws java.io.IOException
java.io.IOException
public void quit() throws java.io.IOException
java.io.IOException
public boolean helo(java.lang.String hostname) throws java.io.IOException
hostname
- the local host name
java.io.IOException
public java.util.List ehlo(java.lang.String hostname) throws java.io.IOException
hostname
- the local host name
java.io.IOException
protected javax.net.ssl.SSLSocketFactory getSSLSocketFactory(javax.net.ssl.TrustManager tm) throws java.security.GeneralSecurityException
tm
- an optional trust manager to use
java.security.GeneralSecurityException
public boolean starttls() throws java.io.IOException
java.io.IOException
public boolean starttls(javax.net.ssl.TrustManager tm) throws java.io.IOException
tm
- the custom trust manager to use
java.io.IOException
public boolean authenticate(java.lang.String mechanism, java.lang.String username, java.lang.String password) throws java.io.IOException
mechanism
- a SASL authentication mechanism, e.g. LOGIN, PLAIN,
CRAM-MD5, GSSAPIusername
- the authentication principalpassword
- the authentication credentials
java.io.IOException
protected void send(java.lang.String command) throws java.io.IOException
command
- the command to send
java.io.IOException
protected int getResponse() throws java.io.IOException
java.io.IOException
protected int getAllResponses() throws java.io.IOException
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |