Methods Summary |
---|
private void | __getReply()
int length;
_newReplyString = true;
_replyLines.setSize(0);
String line = _reader.readLine();
if (line == null)
throw new SMTPConnectionClosedException(
"Connection closed without indication.");
// In case we run into an anomaly we don't want fatal index exceptions
// to be thrown.
length = line.length();
if (length < 3)
throw new MalformedServerReplyException(
"Truncated server reply: " + line);
try
{
String code = line.substring(0, 3);
_replyCode = Integer.parseInt(code);
}
catch (NumberFormatException e)
{
throw new MalformedServerReplyException(
"Could not parse response code.\nServer Reply: " + line);
}
_replyLines.addElement(line);
// Get extra lines if message continues.
if (length > 3 && line.charAt(3) == '-")
{
do
{
line = _reader.readLine();
if (line == null)
throw new SMTPConnectionClosedException(
"Connection closed without indication.");
_replyLines.addElement(line);
// The length() check handles problems that could arise from readLine()
// returning too soon after encountering a naked CR or some other
// anomaly.
}
while (!(line.length() >= 4 && line.charAt(3) != '-" &&
Character.isDigit(line.charAt(0))));
// This is too strong a condition because a non-conforming server
// could screw things up like ftp.funet.fi does for FTP
// line.startsWith(code)));
}
if (_commandSupport_.getListenerCount() > 0)
_commandSupport_.fireReplyReceived(_replyCode, getReplyString());
if (_replyCode == SMTPReply.SERVICE_NOT_AVAILABLE)
throw new SMTPConnectionClosedException(
"SMTP response 421 received. Server closed connection.");
|
private int | __sendCommand(java.lang.String command, java.lang.String args, boolean includeSpace)
String message;
__commandBuffer.setLength(0);
__commandBuffer.append(command);
if (args != null)
{
if (includeSpace)
__commandBuffer.append(' ");
__commandBuffer.append(args);
}
__commandBuffer.append(SocketClient.NETASCII_EOL);
_writer.write(message = __commandBuffer.toString());
_writer.flush();
if (_commandSupport_.getListenerCount() > 0)
_commandSupport_.fireCommandSent(command, message);
__getReply();
return _replyCode;
|
private int | __sendCommand(int command, java.lang.String args, boolean includeSpace)
return __sendCommand(SMTPCommand._commands[command], args, includeSpace);
|
protected void | _connectAction_()Initiates control connections and gets initial reply.
super._connectAction_();
_reader =
new BufferedReader(new InputStreamReader(_input_,
__DEFAULT_ENCODING));
_writer =
new BufferedWriter(new OutputStreamWriter(_output_,
__DEFAULT_ENCODING));
__getReply();
|
public void | addProtocolCommandListener(org.apache.commons.net.ProtocolCommandListener listener)Adds a ProtocolCommandListener. Delegates this task to
{@link #_commandSupport_ _commandSupport_ }.
_commandSupport_.addProtocolCommandListener(listener);
|
public int | data()A convenience method to send the SMTP DATA command to the server,
receive the reply, and return the reply code.
return sendCommand(SMTPCommand.DATA);
|
public void | disconnect()Closes the connection to the SMTP server and sets to null
some internal data so that the memory may be reclaimed by the
garbage collector. The reply text and code information from the
last command is voided so that the memory it used may be reclaimed.
super.disconnect();
_reader = null;
_writer = null;
_replyString = null;
_replyLines.setSize(0);
_newReplyString = false;
|
public int | expn(java.lang.String name)A convenience method to send the SMTP VRFY command to the server,
receive the reply, and return the reply code.
return sendCommand(SMTPCommand.EXPN, name);
|
public int | getReply()Fetches a reply from the SMTP server and returns the integer reply
code. After calling this method, the actual reply text can be accessed
from either calling {@link #getReplyString getReplyString } or
{@link #getReplyStrings getReplyStrings }. Only use this
method if you are implementing your own SMTP client or if you need to
fetch a secondary response from the SMTP server.
__getReply();
return _replyCode;
|
public int | getReplyCode()Returns the integer value of the reply code of the last SMTP reply.
You will usually only use this method after you connect to the
SMTP server to check that the connection was successful since
connect is of type void.
return _replyCode;
|
public java.lang.String | getReplyString()Returns the entire text of the last SMTP server response exactly
as it was received, including all end of line markers in NETASCII
format.
Enumeration en;
StringBuffer buffer;
if (!_newReplyString)
return _replyString;
buffer = new StringBuffer(256);
en = _replyLines.elements();
while (en.hasMoreElements())
{
buffer.append((String)en.nextElement());
buffer.append(SocketClient.NETASCII_EOL);
}
_newReplyString = false;
return (_replyString = buffer.toString());
|
public java.lang.String[] | getReplyStrings()Returns the lines of text from the last SMTP server response as an array
of strings, one entry per line. The end of line markers of each are
stripped from each line.
String[] lines;
lines = new String[_replyLines.size()];
_replyLines.copyInto(lines);
return lines;
|
public int | helo(java.lang.String hostname)A convenience method to send the SMTP HELO command to the server,
receive the reply, and return the reply code.
return sendCommand(SMTPCommand.HELO, hostname);
|
public int | help()A convenience method to send the SMTP HELP command to the server,
receive the reply, and return the reply code.
return sendCommand(SMTPCommand.HELP);
|
public int | help(java.lang.String command)A convenience method to send the SMTP HELP command to the server,
receive the reply, and return the reply code.
return sendCommand(SMTPCommand.HELP, command);
|
public int | mail(java.lang.String reversePath)A convenience method to send the SMTP MAIL command to the server,
receive the reply, and return the reply code.
return __sendCommand(SMTPCommand.MAIL, reversePath, false);
|
public int | noop()A convenience method to send the SMTP NOOP command to the server,
receive the reply, and return the reply code.
return sendCommand(SMTPCommand.NOOP);
|
public int | quit()A convenience method to send the SMTP QUIT command to the server,
receive the reply, and return the reply code.
return sendCommand(SMTPCommand.QUIT);
|
public int | rcpt(java.lang.String forwardPath)A convenience method to send the SMTP RCPT command to the server,
receive the reply, and return the reply code.
return __sendCommand(SMTPCommand.RCPT, forwardPath, false);
|
public void | removeProtocolCommandistener(org.apache.commons.net.ProtocolCommandListener listener)Removes a ProtocolCommandListener. Delegates this task to
{@link #_commandSupport_ _commandSupport_ }.
_commandSupport_.removeProtocolCommandListener(listener);
|
public int | rset()A convenience method to send the SMTP RSET command to the server,
receive the reply, and return the reply code.
return sendCommand(SMTPCommand.RSET);
|
public int | saml(java.lang.String reversePath)A convenience method to send the SMTP SAML command to the server,
receive the reply, and return the reply code.
return sendCommand(SMTPCommand.SAML, reversePath);
|
public int | send(java.lang.String reversePath)A convenience method to send the SMTP SEND command to the server,
receive the reply, and return the reply code.
return sendCommand(SMTPCommand.SEND, reversePath);
|
public int | sendCommand(int command, java.lang.String args)Sends an SMTP command to the server, waits for a reply and returns the
numerical response code. After invocation, for more detailed
information, the actual reply text can be accessed by calling
{@link #getReplyString getReplyString } or
{@link #getReplyStrings getReplyStrings }.
return sendCommand(SMTPCommand._commands[command], args);
|
public int | sendCommand(java.lang.String command)Sends an SMTP command with no arguments to the server, waits for a
reply and returns the numerical response code. After invocation, for
more detailed information, the actual reply text can be accessed by
calling {@link #getReplyString getReplyString } or
{@link #getReplyStrings getReplyStrings }.
return sendCommand(command, null);
|
public int | sendCommand(int command)Sends an SMTP command with no arguments to the server, waits for a
reply and returns the numerical response code. After invocation, for
more detailed information, the actual reply text can be accessed by
calling {@link #getReplyString getReplyString } or
{@link #getReplyStrings getReplyStrings }.
return sendCommand(command, null);
|
public int | sendCommand(java.lang.String command, java.lang.String args)Sends an SMTP command to the server, waits for a reply and returns the
numerical response code. After invocation, for more detailed
information, the actual reply text can be accessed by calling
{@link #getReplyString getReplyString } or
{@link #getReplyStrings getReplyStrings }.
return __sendCommand(command, args, true);
|
public int | soml(java.lang.String reversePath)A convenience method to send the SMTP SOML command to the server,
receive the reply, and return the reply code.
return sendCommand(SMTPCommand.SOML, reversePath);
|
public int | turn()A convenience method to send the SMTP TURN command to the server,
receive the reply, and return the reply code.
return sendCommand(SMTPCommand.TURN);
|
public int | vrfy(java.lang.String user)A convenience method to send the SMTP VRFY command to the server,
receive the reply, and return the reply code.
return sendCommand(SMTPCommand.VRFY, user);
|