org.apache.geronimo.javamail.transport.smtp
Class SMTPTransport

java.lang.Object
  extended byjavax.mail.Service
      extended byjavax.mail.Transport
          extended byorg.apache.geronimo.javamail.transport.smtp.SMTPTransport
Direct Known Subclasses:
SMTPSTransport

public class SMTPTransport
extends javax.mail.Transport

Simple implementation of SMTP transport. Just does plain RFC821-ish delivery.

Supported properties :

There is no way to indicate failure for a given recipient (it's possible to have a recipient address rejected). The sun impl throws exceptions even if others successful), but maybe we do a different way...

TODO : lots. ESMTP, user/pass, indicate failure, etc...

Version:
$Rev: 398634 $ $Date: 2006-05-01 18:56:06 +0200 (Mon, 01 May 2006) $

Nested Class Summary
 class SMTPTransport.SendStatus
          Simple holder class for the address/send status duple, as we can have mixed success for a set of addresses and a message
 
Field Summary
protected static int ADDRESS_NOT_LOCAL
           
protected static int AUTHENTICATION_CHALLENGE
           
protected static int AUTHENTICATION_COMPLETE
           
protected static String AUTHENTICATION_CRAMMD5
           
protected static String AUTHENTICATION_DIGESTMD5
           
protected static String AUTHENTICATION_LOGIN
           
protected static String AUTHENTICATION_PLAIN
           
protected static int COMMAND_ACCEPTED
           
protected static int COMMAND_NOT_IMPLEMENTED
           
protected static int COMMAND_PARAMETER_NOT_IMPLEMENTED
           
protected static int COMMAND_SYNTAX_ERROR
           
protected static char CR
          constants for EOL termination
protected  PrintStream debugStream
           
protected static String DEFAULT_MAIL_HOST
           
protected static int DEFAULT_MAIL_SMTP_PORT
           
protected static int DEFAULT_MAIL_SMTPS_PORT
           
protected  int defaultPort
           
protected  String host
           
protected  InputStream inputStream
           
protected static int INSUFFICIENT_STORAGE
           
protected static int INVALID_COMMAND_SEQUENCE
           
protected static int INVALID_MAILBOX
           
protected  org.apache.geronimo.javamail.transport.smtp.SMTPReply lastServerResponse
           
protected static char LF
           
protected  String localHost
           
protected static String MAIL_LOCALHOST
          property keys for top level session properties.
protected static String MAIL_SMTP_AUTH
          property keys for protocol properties.
protected static String MAIL_SMTP_DSN_NOTIFY
           
protected static String MAIL_SMTP_DSN_RET
           
protected static String MAIL_SMTP_EHLO
           
protected static String MAIL_SMTP_ENCODE_TRACE
           
protected static String MAIL_SMTP_EXTENSION
           
protected static String MAIL_SMTP_FACTORY_CLASS
           
protected static String MAIL_SMTP_FACTORY_FALLBACK
           
protected static String MAIL_SMTP_FACTORY_PORT
           
protected static String MAIL_SMTP_FROM
           
protected static String MAIL_SMTP_LOCALADDRESS
           
protected static String MAIL_SMTP_LOCALHOST
           
protected static String MAIL_SMTP_LOCALPORT
           
protected static String MAIL_SMTP_PORT
           
protected static String MAIL_SMTP_QUITWAIT
           
protected static String MAIL_SMTP_REPORT_SUCCESS
           
protected static String MAIL_SMTP_SASL_REALM
           
protected static String MAIL_SMTP_SENDPARTIAL
           
protected static String MAIL_SMTP_STARTTLS_ENABLE
           
protected static String MAIL_SMTP_SUBMITTER
           
protected static String MAIL_SMTP_TIMEOUT
           
protected static String MAIL_SMTP_TLS
           
protected static String MAIL_SSLFACTORY_CLASS
           
protected static int MAILBOX_BUSY
           
protected static int MAILBOX_FULL
           
protected static int MAILBOX_NOT_FOUND
           
protected static int MIN_MILLIS
           
protected  OutputStream outputStream
           
protected static int PARAMETER_SYNTAX_ERROR
           
protected  String password
           
protected  int port
           
protected static int PROCESSING_ERROR
           
protected  String protocol
           
protected  String realm
           
protected  boolean reportSuccess
           
protected  HashMap serverAuthenticationMechanisms
           
protected  HashMap serverExtensionArgs
           
protected  boolean serverTLS
           
protected static int SERVICE_CLOSING
           
protected static int SERVICE_NOT_AVAILABLE
           
protected static int SERVICE_READY
           
protected  Socket socket
           
protected  boolean sslConnection
           
protected static int START_MAIL_INPUT
           
protected static int TIMEOUT
           
protected static int TRANSACTION_FAILED
           
protected static int USER_NOT_LOCAL
           
protected  String username
           
protected  boolean useTLS
           
 
Fields inherited from class javax.mail.Service
debug, session, url
 
Constructor Summary
  SMTPTransport(javax.mail.Session session, javax.mail.URLName name)
          Normal constructor for an SMTPTransport() object.
protected SMTPTransport(javax.mail.Session session, javax.mail.URLName name, String protocol, int defaultPort, boolean sslConnection)
          Common constructor used by the SMTPTransport and SMTPSTransport classes to do common initialization of defaults.
 
Method Summary
 void close()
          Close the connection.
protected  void closeServerConnection()
          Close the server connection at termination.
 void connect(Socket socket)
          Connect to a server using an already created socket.
protected  void debugOut(String message)
          Internal debug output routine.
protected  void debugOut(String message, Throwable e)
          Internal debugging routine for reporting exceptions.
protected  javax.mail.Address[] expandGroups(javax.mail.Address[] addresses)
          Expand the address list by converting any group addresses into single address targets.
 String extensionParameter(String name)
          Retrieve any argument information associated with a extension reported back by the server on the EHLO command.
protected  String fixEmailAddress(String mail)
          Convert an InternetAddress into a form sendable on an SMTP mail command.
protected  javax.mail.MessagingException generateExceptionChain(SMTPTransport.SendStatus[] stats, boolean reportSuccess)
          Turn a series of send status items into a chain of exceptions indicating the state of each send operation.
protected  void getConnectedSocket()
          Creates a connected socket
protected  void getConnectedSSLSocket()
          Creates a connected SSL socket for an initial SSL connection.
protected  void getConnectedTLSSocket()
          Switch the connection to using TLS level security, switching to an SSL socket.
protected  void getConnection(String host, int port, String username, String password)
          Create a transport connection object and connect it to the target server.
protected  int getIntProtocolProperty(String name, int defaultValue)
          Get a property associated with this mail session as an integer value.
protected  int getIntSessionProperty(String name, int defaultValue)
          Get a property associated with this mail session as an integer value.
 String getLastServerResponse()
          Retrieve the last response received from the SMTP server.
 String getLocalHost()
          Retrieve the local client host name.
protected  String getProtocolProperty(String name)
          Get a property associated with this mail protocol.
protected  String getProtocolProperty(String name, String defaultValue)
          Get a property associated with this mail session.
protected  org.apache.geronimo.javamail.transport.smtp.SMTPReply getReply()
          Get a reply line for an SMTP command.
 boolean getReportSuccess()
          Return the current reportSuccess property.
 String getSASLRealm()
          Retrieve the SASL realm used for DIGEST-MD5 authentication.
protected  String getSessionProperty(String name)
          Get a property associated with this mail session.
protected  String getSessionProperty(String name, String defaultValue)
          Get a property associated with this mail session.
 boolean getStartTLS()
          Return the current startTLS property.
protected  boolean getWelcome()
          Get the servers welcome blob from the wire....
protected  boolean isProtocolPropertyFalse(String name)
          Process a session property as a boolean value, returning either true or false.
protected  boolean isProtocolPropertyTrue(String name)
          Process a session property as a boolean value, returning either true or false.
protected  boolean isSessionPropertyFalse(String name)
          Process a session property as a boolean value, returning either true or false.
protected  boolean isSessionPropertyTrue(String name)
          Process a session property as a boolean value, returning either true or false.
protected  boolean processAuthentication()
          Authenticate with the server, if necessary (or possible).
protected  void processExtension(String extension)
          Process an extension string passed back as the EHLP response.
protected  boolean protocolConnect(String host, int port, String username, String password)
          Do the protocol connection for an SMTP transport.
protected  String receiveLine()
          Receives one line from the server.
protected  String receiveLine(int delayMillis)
          Receives one line from the server.
protected  void resetConnection()
          Reset the server connection after an error.
protected  org.apache.geronimo.javamail.transport.smtp.SMTPReply sendCommand(String data)
          Send a command to the server, returning the first response line back as a reply.
protected  void sendData(javax.mail.Message msg)
          Sends the data in the message down the socket.
protected  boolean sendEhlo()
          Send the EHLO command to the SMTP server.
protected  boolean sendHandshake()
          Start the handshake process with the server, including setting up and TLS-level work.
protected  void sendHelo()
          Send the HELO command to the SMTP server.
protected  void sendLine(String data)
          Sends a message down the socket and terminates with the appropriate CRLF
protected  boolean sendMailFrom(javax.mail.Message message)
          Set the sender for this mail.
 void sendMessage(javax.mail.Message message, javax.mail.Address[] addresses)
          Send a message to multiple addressees.
protected  void sendQuit()
          Sends the QUIT message and receieves the response
protected  SMTPTransport.SendStatus sendRcptTo(javax.mail.internet.InternetAddress addr, String dsn)
          Sets a receiver address for the current message
 void setLocalHost(String localHost)
          Explicitly set the local host information.
 void setReportSuccess(boolean report)
          Set a new value for the reportSuccess property.
 void setSASLRealm(String name)
          Explicitly set the SASL realm used for DIGEST-MD5 authenticaiton.
 void setStartTLS(boolean start)
          Set a new value for the startTLS property.
protected  boolean supportsAuthentication(String mechanism)
          Determine if the target server supports a given authentication mechanism.
 boolean supportsExtension(String name)
          Tests whether the target server supports a named extension.
 
Methods inherited from class javax.mail.Transport
addTransportListener, notifyTransportListeners, removeTransportListener, send, send
 
Methods inherited from class javax.mail.Service
addConnectionListener, connect, connect, connect, finalize, getURLName, isConnected, notifyConnectionListeners, queueEvent, removeConnectionListener, setConnected, setURLName, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CR

protected static final char CR
constants for EOL termination

See Also:
Constant Field Values

LF

protected static final char LF
See Also:
Constant Field Values

MAIL_LOCALHOST

protected static final String MAIL_LOCALHOST
property keys for top level session properties.

See Also:
Constant Field Values

MAIL_SSLFACTORY_CLASS

protected static final String MAIL_SSLFACTORY_CLASS
See Also:
Constant Field Values

MAIL_SMTP_AUTH

protected static final String MAIL_SMTP_AUTH
property keys for protocol properties. The actual property name will be appended with "mail." + protocol + ".", where the protocol is either "smtp" or "smtps".

See Also:
Constant Field Values

MAIL_SMTP_PORT

protected static final String MAIL_SMTP_PORT
See Also:
Constant Field Values

MAIL_SMTP_LOCALHOST

protected static final String MAIL_SMTP_LOCALHOST
See Also:
Constant Field Values

MAIL_SMTP_TIMEOUT

protected static final String MAIL_SMTP_TIMEOUT
See Also:
Constant Field Values

MAIL_SMTP_SASL_REALM

protected static final String MAIL_SMTP_SASL_REALM
See Also:
Constant Field Values

MAIL_SMTP_TLS

protected static final String MAIL_SMTP_TLS
See Also:
Constant Field Values

MAIL_SMTP_FACTORY_CLASS

protected static final String MAIL_SMTP_FACTORY_CLASS
See Also:
Constant Field Values

MAIL_SMTP_FACTORY_FALLBACK

protected static final String MAIL_SMTP_FACTORY_FALLBACK
See Also:
Constant Field Values

MAIL_SMTP_FACTORY_PORT

protected static final String MAIL_SMTP_FACTORY_PORT
See Also:
Constant Field Values

MAIL_SMTP_REPORT_SUCCESS

protected static final String MAIL_SMTP_REPORT_SUCCESS
See Also:
Constant Field Values

MAIL_SMTP_STARTTLS_ENABLE

protected static final String MAIL_SMTP_STARTTLS_ENABLE
See Also:
Constant Field Values

MAIL_SMTP_DSN_NOTIFY

protected static final String MAIL_SMTP_DSN_NOTIFY
See Also:
Constant Field Values

MAIL_SMTP_SENDPARTIAL

protected static final String MAIL_SMTP_SENDPARTIAL
See Also:
Constant Field Values

MAIL_SMTP_LOCALADDRESS

protected static final String MAIL_SMTP_LOCALADDRESS
See Also:
Constant Field Values

MAIL_SMTP_LOCALPORT

protected static final String MAIL_SMTP_LOCALPORT
See Also:
Constant Field Values

MAIL_SMTP_QUITWAIT

protected static final String MAIL_SMTP_QUITWAIT
See Also:
Constant Field Values

MAIL_SMTP_FROM

protected static final String MAIL_SMTP_FROM
See Also:
Constant Field Values

MAIL_SMTP_DSN_RET

protected static final String MAIL_SMTP_DSN_RET
See Also:
Constant Field Values

MAIL_SMTP_SUBMITTER

protected static final String MAIL_SMTP_SUBMITTER
See Also:
Constant Field Values

MAIL_SMTP_EXTENSION

protected static final String MAIL_SMTP_EXTENSION
See Also:
Constant Field Values

MAIL_SMTP_EHLO

protected static final String MAIL_SMTP_EHLO
See Also:
Constant Field Values

MAIL_SMTP_ENCODE_TRACE

protected static final String MAIL_SMTP_ENCODE_TRACE
See Also:
Constant Field Values

MIN_MILLIS

protected static final int MIN_MILLIS
See Also:
Constant Field Values

TIMEOUT

protected static final int TIMEOUT
See Also:
Constant Field Values

DEFAULT_MAIL_HOST

protected static final String DEFAULT_MAIL_HOST
See Also:
Constant Field Values

DEFAULT_MAIL_SMTP_PORT

protected static final int DEFAULT_MAIL_SMTP_PORT
See Also:
Constant Field Values

DEFAULT_MAIL_SMTPS_PORT

protected static final int DEFAULT_MAIL_SMTPS_PORT
See Also:
Constant Field Values

SERVICE_READY

protected static final int SERVICE_READY
See Also:
Constant Field Values

SERVICE_CLOSING

protected static final int SERVICE_CLOSING
See Also:
Constant Field Values

AUTHENTICATION_COMPLETE

protected static final int AUTHENTICATION_COMPLETE
See Also:
Constant Field Values

COMMAND_ACCEPTED

protected static final int COMMAND_ACCEPTED
See Also:
Constant Field Values

ADDRESS_NOT_LOCAL

protected static final int ADDRESS_NOT_LOCAL
See Also:
Constant Field Values

AUTHENTICATION_CHALLENGE

protected static final int AUTHENTICATION_CHALLENGE
See Also:
Constant Field Values

START_MAIL_INPUT

protected static final int START_MAIL_INPUT
See Also:
Constant Field Values

SERVICE_NOT_AVAILABLE

protected static final int SERVICE_NOT_AVAILABLE
See Also:
Constant Field Values

MAILBOX_BUSY

protected static final int MAILBOX_BUSY
See Also:
Constant Field Values

PROCESSING_ERROR

protected static final int PROCESSING_ERROR
See Also:
Constant Field Values

INSUFFICIENT_STORAGE

protected static final int INSUFFICIENT_STORAGE
See Also:
Constant Field Values

COMMAND_SYNTAX_ERROR

protected static final int COMMAND_SYNTAX_ERROR
See Also:
Constant Field Values

PARAMETER_SYNTAX_ERROR

protected static final int PARAMETER_SYNTAX_ERROR
See Also:
Constant Field Values

COMMAND_NOT_IMPLEMENTED

protected static final int COMMAND_NOT_IMPLEMENTED
See Also:
Constant Field Values

INVALID_COMMAND_SEQUENCE

protected static final int INVALID_COMMAND_SEQUENCE
See Also:
Constant Field Values

COMMAND_PARAMETER_NOT_IMPLEMENTED

protected static final int COMMAND_PARAMETER_NOT_IMPLEMENTED
See Also:
Constant Field Values

MAILBOX_NOT_FOUND

protected static final int MAILBOX_NOT_FOUND
See Also:
Constant Field Values

USER_NOT_LOCAL

protected static final int USER_NOT_LOCAL
See Also:
Constant Field Values

MAILBOX_FULL

protected static final int MAILBOX_FULL
See Also:
Constant Field Values

INVALID_MAILBOX

protected static final int INVALID_MAILBOX
See Also:
Constant Field Values

TRANSACTION_FAILED

protected static final int TRANSACTION_FAILED
See Also:
Constant Field Values

AUTHENTICATION_PLAIN

protected static final String AUTHENTICATION_PLAIN
See Also:
Constant Field Values

AUTHENTICATION_LOGIN

protected static final String AUTHENTICATION_LOGIN
See Also:
Constant Field Values

AUTHENTICATION_CRAMMD5

protected static final String AUTHENTICATION_CRAMMD5
See Also:
Constant Field Values

AUTHENTICATION_DIGESTMD5

protected static final String AUTHENTICATION_DIGESTMD5
See Also:
Constant Field Values

protocol

protected String protocol

host

protected String host

defaultPort

protected int defaultPort

port

protected int port

socket

protected Socket socket

localHost

protected String localHost

inputStream

protected InputStream inputStream

outputStream

protected OutputStream outputStream

serverAuthenticationMechanisms

protected HashMap serverAuthenticationMechanisms

serverExtensionArgs

protected HashMap serverExtensionArgs

reportSuccess

protected boolean reportSuccess

serverTLS

protected boolean serverTLS

useTLS

protected boolean useTLS

sslConnection

protected boolean sslConnection

username

protected String username

password

protected String password

realm

protected String realm

lastServerResponse

protected org.apache.geronimo.javamail.transport.smtp.SMTPReply lastServerResponse

debugStream

protected PrintStream debugStream
Constructor Detail

SMTPTransport

public SMTPTransport(javax.mail.Session session,
                     javax.mail.URLName name)
Normal constructor for an SMTPTransport() object. This constructor is used to build a transport instance for the "smtp" protocol.

Parameters:
session - The attached session.
name - An optional URLName object containing target information.

SMTPTransport

protected SMTPTransport(javax.mail.Session session,
                        javax.mail.URLName name,
                        String protocol,
                        int defaultPort,
                        boolean sslConnection)
Common constructor used by the SMTPTransport and SMTPSTransport classes to do common initialization of defaults.

Parameters:
session - The host session instance.
name - The URLName of the target.
protocol - The protocol type (either "smtp" or "smtps". This helps us in retrieving protocol-specific session properties.
defaultPort - The default port used by this protocol. For "smtp", this will be 25. The default for "smtps" is 465.
sslConnection - Indicates whether an SSL connection should be used to initial contact the server. This is different from the STARTTLS support, which switches the connection to SSL after the initial startup.
Method Detail

connect

public void connect(Socket socket)
             throws javax.mail.MessagingException
Connect to a server using an already created socket. This connection is just like any other connection, except we will not create a new socket.

Parameters:
socket - The socket connection to use.
Throws:
javax.mail.MessagingException

protocolConnect

protected boolean protocolConnect(String host,
                                  int port,
                                  String username,
                                  String password)
                           throws javax.mail.MessagingException
Do the protocol connection for an SMTP transport. This handles server authentication, if possible. Returns false if unable to connect to the server.

Parameters:
host - The target host name.
port - The server port number.
password - The server password. Might not be sent directly if more sophisticated authentication is used.
Returns:
true if we were able to connect to the server properly, false for any failures.
Throws:
javax.mail.MessagingException

sendMessage

public void sendMessage(javax.mail.Message message,
                        javax.mail.Address[] addresses)
                 throws javax.mail.MessagingException
Send a message to multiple addressees.

Parameters:
message - The message we're sending.
addresses - An array of addresses to send to.
Throws:
javax.mail.MessagingException

close

public void close()
           throws javax.mail.MessagingException
Close the connection. On completion, we'll be disconnected from the server and unable to send more data.

Throws:
javax.mail.MessagingException

generateExceptionChain

protected javax.mail.MessagingException generateExceptionChain(SMTPTransport.SendStatus[] stats,
                                                               boolean reportSuccess)
Turn a series of send status items into a chain of exceptions indicating the state of each send operation.

Parameters:
stats - The list of SendStatus items.
reportSuccess - Indicates whether we should include the report success items.
Returns:
The head of a chained list of MessagingExceptions.

resetConnection

protected void resetConnection()
                        throws javax.mail.MessagingException
Reset the server connection after an error.

Throws:
javax.mail.MessagingException

expandGroups

protected javax.mail.Address[] expandGroups(javax.mail.Address[] addresses)
                                     throws javax.mail.MessagingException
Expand the address list by converting any group addresses into single address targets.

Parameters:
addresses - The input array of addresses.
Returns:
The expanded array of addresses.
Throws:
javax.mail.MessagingException

getConnection

protected void getConnection(String host,
                             int port,
                             String username,
                             String password)
                      throws IOException
Create a transport connection object and connect it to the target server.

Parameters:
host - The target server host.
port - The connection port.
Throws:
javax.mail.MessagingException
IOException

getProtocolProperty

protected String getProtocolProperty(String name)
Get a property associated with this mail protocol.

Parameters:
name - The name of the property.
Returns:
The property value (returns null if the property has not been set).

getSessionProperty

protected String getSessionProperty(String name)
Get a property associated with this mail session.

Parameters:
name - The name of the property.
Returns:
The property value (returns null if the property has not been set).

getSessionProperty

protected String getSessionProperty(String name,
                                    String defaultValue)
Get a property associated with this mail session. Returns the provided default if it doesn't exist.

Parameters:
name - The name of the property.
defaultValue - The default value to return if the property doesn't exist.
Returns:
The property value (returns defaultValue if the property has not been set).

getProtocolProperty

protected String getProtocolProperty(String name,
                                     String defaultValue)
Get a property associated with this mail session. Returns the provided default if it doesn't exist.

Parameters:
name - The name of the property.
defaultValue - The default value to return if the property doesn't exist.
Returns:
The property value (returns defaultValue if the property has not been set).

getIntSessionProperty

protected int getIntSessionProperty(String name,
                                    int defaultValue)
Get a property associated with this mail session as an integer value. Returns the default value if the property doesn't exist or it doesn't have a valid int value.

Parameters:
name - The name of the property.
defaultValue - The default value to return if the property doesn't exist.
Returns:
The property value converted to an int.

getIntProtocolProperty

protected int getIntProtocolProperty(String name,
                                     int defaultValue)
Get a property associated with this mail session as an integer value. Returns the default value if the property doesn't exist or it doesn't have a valid int value.

Parameters:
name - The name of the property.
defaultValue - The default value to return if the property doesn't exist.
Returns:
The property value converted to an int.

isProtocolPropertyTrue

protected boolean isProtocolPropertyTrue(String name)
Process a session property as a boolean value, returning either true or false.

Returns:
True if the property value is "true". Returns false for any other value (including null).

isSessionPropertyTrue

protected boolean isSessionPropertyTrue(String name)
Process a session property as a boolean value, returning either true or false.

Returns:
True if the property value is "true". Returns false for any other value (including null).

isSessionPropertyFalse

protected boolean isSessionPropertyFalse(String name)
Process a session property as a boolean value, returning either true or false.

Returns:
True if the property value is "false". Returns false for other value (including null).

isProtocolPropertyFalse

protected boolean isProtocolPropertyFalse(String name)
Process a session property as a boolean value, returning either true or false.

Returns:
True if the property value is "false". Returns false for other value (including null).

closeServerConnection

protected void closeServerConnection()
Close the server connection at termination.


getConnectedSocket

protected void getConnectedSocket()
                           throws IOException
Creates a connected socket

Throws:
javax.mail.MessagingException
IOException

getConnectedSSLSocket

protected void getConnectedSSLSocket()
                              throws IOException
Creates a connected SSL socket for an initial SSL connection.

Throws:
javax.mail.MessagingException
IOException

getConnectedTLSSocket

protected void getConnectedTLSSocket()
                              throws javax.mail.MessagingException
Switch the connection to using TLS level security, switching to an SSL socket.

Throws:
javax.mail.MessagingException

getWelcome

protected boolean getWelcome()
                      throws javax.mail.MessagingException
Get the servers welcome blob from the wire....

Throws:
javax.mail.MessagingException

sendData

protected void sendData(javax.mail.Message msg)
                 throws javax.mail.MessagingException
Sends the data in the message down the socket. This presumes the server is in the right place and ready for getting the DATA message and the data right place in the sequence

Throws:
javax.mail.MessagingException

sendQuit

protected void sendQuit()
                 throws javax.mail.MessagingException
Sends the QUIT message and receieves the response

Throws:
javax.mail.MessagingException

sendRcptTo

protected SMTPTransport.SendStatus sendRcptTo(javax.mail.internet.InternetAddress addr,
                                              String dsn)
                                       throws javax.mail.MessagingException
Sets a receiver address for the current message

Parameters:
addr - The target address.
dsn - An optional notification address appended to the MAIL command.
Returns:
The status for this particular send operation.
Throws:
javax.mail.MessagingException

sendMailFrom

protected boolean sendMailFrom(javax.mail.Message message)
                        throws javax.mail.MessagingException
Set the sender for this mail.

Parameters:
message - The message we're sending.
Throws:
javax.mail.MessagingException

sendCommand

protected org.apache.geronimo.javamail.transport.smtp.SMTPReply sendCommand(String data)
                                                                     throws javax.mail.MessagingException
Send a command to the server, returning the first response line back as a reply.

Parameters:
data - The data to send.
Returns:
A reply object with the reply line.
Throws:
javax.mail.MessagingException

sendLine

protected void sendLine(String data)
                 throws javax.mail.MessagingException
Sends a message down the socket and terminates with the appropriate CRLF

Throws:
javax.mail.MessagingException

receiveLine

protected String receiveLine()
                      throws javax.mail.MessagingException
Receives one line from the server. A line is a sequence of bytes terminated by a CRLF

Returns:
the line from the server as String
Throws:
javax.mail.MessagingException

getReply

protected org.apache.geronimo.javamail.transport.smtp.SMTPReply getReply()
                                                                  throws javax.mail.MessagingException
Get a reply line for an SMTP command.

Returns:
An SMTP reply object from the stream.
Throws:
javax.mail.MessagingException

getLastServerResponse

public String getLastServerResponse()
Retrieve the last response received from the SMTP server.

Returns:
The raw response string (including the error code) returned from the SMTP server.

receiveLine

protected String receiveLine(int delayMillis)
                      throws javax.mail.MessagingException
Receives one line from the server. A line is a sequence of bytes terminated by a CRLF

Returns:
the line from the server as String
Throws:
javax.mail.MessagingException

fixEmailAddress

protected String fixEmailAddress(String mail)
Convert an InternetAddress into a form sendable on an SMTP mail command. InternetAddress.getAddress() generally returns just the address portion of the full address, minus route address markers. We need to ensure we have an address with '<' and '>' delimiters.

Parameters:
mail - The mail address returned from InternetAddress.getAddress().
Returns:
A string formatted for sending.

sendHandshake

protected boolean sendHandshake()
                         throws javax.mail.MessagingException
Start the handshake process with the server, including setting up and TLS-level work. At the completion of this task, we should be ready to authenticate with the server, if needed.

Throws:
javax.mail.MessagingException

sendEhlo

protected boolean sendEhlo()
                    throws javax.mail.MessagingException
Send the EHLO command to the SMTP server.

Returns:
True if the command was accepted ok, false for any errors.
Throws:
SMTPTransportException
MalformedSMTPReplyException
javax.mail.MessagingException

sendHelo

protected void sendHelo()
                 throws javax.mail.MessagingException
Send the HELO command to the SMTP server.

Throws:
javax.mail.MessagingException

getLocalHost

public String getLocalHost()
                    throws javax.mail.MessagingException
Retrieve the local client host name.

Returns:
The string version of the local host name.
Throws:
SMTPTransportException
javax.mail.MessagingException

getReportSuccess

public boolean getReportSuccess()
Return the current reportSuccess property.

Returns:
The current reportSuccess property.

setReportSuccess

public void setReportSuccess(boolean report)
Set a new value for the reportSuccess property.

Parameters:
report - The new setting.

getStartTLS

public boolean getStartTLS()
Return the current startTLS property.

Returns:
The current startTLS property.

setStartTLS

public void setStartTLS(boolean start)
Set a new value for the startTLS property.

Parameters:
start - The new setting.

getSASLRealm

public String getSASLRealm()
Retrieve the SASL realm used for DIGEST-MD5 authentication. This will either be explicitly set, or retrieved using the mail.smtp.sasl.realm session property.

Returns:
The current realm information (which can be null).

setSASLRealm

public void setSASLRealm(String name)
Explicitly set the SASL realm used for DIGEST-MD5 authenticaiton.

Parameters:
name - The new realm name.

setLocalHost

public void setLocalHost(String localHost)
Explicitly set the local host information.

Parameters:
localHost - The new localHost name.

processExtension

protected void processExtension(String extension)
Process an extension string passed back as the EHLP response.

Parameters:
extension - The string value of the extension (which will be of the form "NAME arguments").

extensionParameter

public String extensionParameter(String name)
Retrieve any argument information associated with a extension reported back by the server on the EHLO command.

Parameters:
name - The name of the target server extension.
Returns:
Any argument passed on a server extension. Returns null if the extension did not include an argument or the extension was not supported.

supportsExtension

public boolean supportsExtension(String name)
Tests whether the target server supports a named extension.

Parameters:
name - The target extension name.
Returns:
true if the target server reported on the EHLO command that is supports the targer server, false if the extension was not supported.

supportsAuthentication

protected boolean supportsAuthentication(String mechanism)
Determine if the target server supports a given authentication mechanism.

Parameters:
mechanism - The mechanism name.
Returns:
true if the server EHLO response indicates it supports the mechanism, false otherwise.

processAuthentication

protected boolean processAuthentication()
                                 throws javax.mail.MessagingException
Authenticate with the server, if necessary (or possible).

Returns:
true if we are ok to proceed, false for an authentication failures.
Throws:
javax.mail.MessagingException

debugOut

protected void debugOut(String message)
Internal debug output routine.


debugOut

protected void debugOut(String message,
                        Throwable e)
Internal debugging routine for reporting exceptions.

Parameters:
message - A message associated with the exception context.
e - The received exception.


Copyright © 2003-2007 Apache Software Foundation. All Rights Reserved.