|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.mail.Service
javax.mail.Transport
org.apache.geronimo.javamail.transport.smtp.SMTPTransport
Simple implementation of SMTP transport. Just does plain RFC821-ish delivery.
Supported properties :
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 |
protected static final char CR
protected static final char LF
protected static final String MAIL_LOCALHOST
protected static final String MAIL_SSLFACTORY_CLASS
protected static final String MAIL_SMTP_AUTH
protected static final String MAIL_SMTP_PORT
protected static final String MAIL_SMTP_LOCALHOST
protected static final String MAIL_SMTP_TIMEOUT
protected static final String MAIL_SMTP_SASL_REALM
protected static final String MAIL_SMTP_TLS
protected static final String MAIL_SMTP_FACTORY_CLASS
protected static final String MAIL_SMTP_FACTORY_FALLBACK
protected static final String MAIL_SMTP_FACTORY_PORT
protected static final String MAIL_SMTP_REPORT_SUCCESS
protected static final String MAIL_SMTP_STARTTLS_ENABLE
protected static final String MAIL_SMTP_DSN_NOTIFY
protected static final String MAIL_SMTP_SENDPARTIAL
protected static final String MAIL_SMTP_LOCALADDRESS
protected static final String MAIL_SMTP_LOCALPORT
protected static final String MAIL_SMTP_QUITWAIT
protected static final String MAIL_SMTP_FROM
protected static final String MAIL_SMTP_DSN_RET
protected static final String MAIL_SMTP_SUBMITTER
protected static final String MAIL_SMTP_EXTENSION
protected static final String MAIL_SMTP_EHLO
protected static final String MAIL_SMTP_ENCODE_TRACE
protected static final int MIN_MILLIS
protected static final int TIMEOUT
protected static final String DEFAULT_MAIL_HOST
protected static final int DEFAULT_MAIL_SMTP_PORT
protected static final int DEFAULT_MAIL_SMTPS_PORT
protected static final int SERVICE_READY
protected static final int SERVICE_CLOSING
protected static final int AUTHENTICATION_COMPLETE
protected static final int COMMAND_ACCEPTED
protected static final int ADDRESS_NOT_LOCAL
protected static final int AUTHENTICATION_CHALLENGE
protected static final int START_MAIL_INPUT
protected static final int SERVICE_NOT_AVAILABLE
protected static final int MAILBOX_BUSY
protected static final int PROCESSING_ERROR
protected static final int INSUFFICIENT_STORAGE
protected static final int COMMAND_SYNTAX_ERROR
protected static final int PARAMETER_SYNTAX_ERROR
protected static final int COMMAND_NOT_IMPLEMENTED
protected static final int INVALID_COMMAND_SEQUENCE
protected static final int COMMAND_PARAMETER_NOT_IMPLEMENTED
protected static final int MAILBOX_NOT_FOUND
protected static final int USER_NOT_LOCAL
protected static final int MAILBOX_FULL
protected static final int INVALID_MAILBOX
protected static final int TRANSACTION_FAILED
protected static final String AUTHENTICATION_PLAIN
protected static final String AUTHENTICATION_LOGIN
protected static final String AUTHENTICATION_CRAMMD5
protected static final String AUTHENTICATION_DIGESTMD5
protected String protocol
protected String host
protected int defaultPort
protected int port
protected Socket socket
protected String localHost
protected InputStream inputStream
protected OutputStream outputStream
protected HashMap serverAuthenticationMechanisms
protected HashMap serverExtensionArgs
protected boolean reportSuccess
protected boolean serverTLS
protected boolean useTLS
protected boolean sslConnection
protected String username
protected String password
protected String realm
protected org.apache.geronimo.javamail.transport.smtp.SMTPReply lastServerResponse
protected PrintStream debugStream
Constructor Detail |
public SMTPTransport(javax.mail.Session session, javax.mail.URLName name)
session
- The attached session.name
- An optional URLName object containing target information.protected SMTPTransport(javax.mail.Session session, javax.mail.URLName name, String protocol, int defaultPort, boolean sslConnection)
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 |
public void connect(Socket socket) throws javax.mail.MessagingException
socket
- The socket connection to use.
javax.mail.MessagingException
protected boolean protocolConnect(String host, int port, String username, String password) throws javax.mail.MessagingException
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.
javax.mail.MessagingException
public void sendMessage(javax.mail.Message message, javax.mail.Address[] addresses) throws javax.mail.MessagingException
message
- The message we're sending.addresses
- An array of addresses to send to.
javax.mail.MessagingException
public void close() throws javax.mail.MessagingException
javax.mail.MessagingException
protected javax.mail.MessagingException generateExceptionChain(SMTPTransport.SendStatus[] stats, boolean reportSuccess)
stats
- The list of SendStatus items.reportSuccess
- Indicates whether we should include the report success items.
protected void resetConnection() throws javax.mail.MessagingException
javax.mail.MessagingException
protected javax.mail.Address[] expandGroups(javax.mail.Address[] addresses) throws javax.mail.MessagingException
addresses
- The input array of addresses.
javax.mail.MessagingException
protected void getConnection(String host, int port, String username, String password) throws IOException
host
- The target server host.port
- The connection port.
javax.mail.MessagingException
IOException
protected String getProtocolProperty(String name)
name
- The name of the property.
protected String getSessionProperty(String name)
name
- The name of the property.
protected String getSessionProperty(String name, String defaultValue)
name
- The name of the property.defaultValue
- The default value to return if the property doesn't exist.
protected String getProtocolProperty(String name, String defaultValue)
name
- The name of the property.defaultValue
- The default value to return if the property doesn't exist.
protected int getIntSessionProperty(String name, int defaultValue)
name
- The name of the property.defaultValue
- The default value to return if the property doesn't exist.
protected int getIntProtocolProperty(String name, int defaultValue)
name
- The name of the property.defaultValue
- The default value to return if the property doesn't exist.
protected boolean isProtocolPropertyTrue(String name)
protected boolean isSessionPropertyTrue(String name)
protected boolean isSessionPropertyFalse(String name)
protected boolean isProtocolPropertyFalse(String name)
protected void closeServerConnection()
protected void getConnectedSocket() throws IOException
javax.mail.MessagingException
IOException
protected void getConnectedSSLSocket() throws IOException
javax.mail.MessagingException
IOException
protected void getConnectedTLSSocket() throws javax.mail.MessagingException
javax.mail.MessagingException
protected boolean getWelcome() throws javax.mail.MessagingException
javax.mail.MessagingException
protected void sendData(javax.mail.Message msg) throws javax.mail.MessagingException
javax.mail.MessagingException
protected void sendQuit() throws javax.mail.MessagingException
javax.mail.MessagingException
protected SMTPTransport.SendStatus sendRcptTo(javax.mail.internet.InternetAddress addr, String dsn) throws javax.mail.MessagingException
addr
- The target address.dsn
- An optional notification address appended to the MAIL command.
javax.mail.MessagingException
protected boolean sendMailFrom(javax.mail.Message message) throws javax.mail.MessagingException
message
- The message we're sending.
javax.mail.MessagingException
protected org.apache.geronimo.javamail.transport.smtp.SMTPReply sendCommand(String data) throws javax.mail.MessagingException
data
- The data to send.
javax.mail.MessagingException
protected void sendLine(String data) throws javax.mail.MessagingException
javax.mail.MessagingException
protected String receiveLine() throws javax.mail.MessagingException
javax.mail.MessagingException
protected org.apache.geronimo.javamail.transport.smtp.SMTPReply getReply() throws javax.mail.MessagingException
javax.mail.MessagingException
public String getLastServerResponse()
protected String receiveLine(int delayMillis) throws javax.mail.MessagingException
javax.mail.MessagingException
protected String fixEmailAddress(String mail)
mail
- The mail address returned from InternetAddress.getAddress().
protected boolean sendHandshake() throws javax.mail.MessagingException
javax.mail.MessagingException
protected boolean sendEhlo() throws javax.mail.MessagingException
SMTPTransportException
MalformedSMTPReplyException
javax.mail.MessagingException
protected void sendHelo() throws javax.mail.MessagingException
javax.mail.MessagingException
public String getLocalHost() throws javax.mail.MessagingException
SMTPTransportException
javax.mail.MessagingException
public boolean getReportSuccess()
public void setReportSuccess(boolean report)
report
- The new setting.public boolean getStartTLS()
public void setStartTLS(boolean start)
start
- The new setting.public String getSASLRealm()
public void setSASLRealm(String name)
name
- The new realm name.public void setLocalHost(String localHost)
localHost
- The new localHost name.protected void processExtension(String extension)
extension
- The string value of the extension (which will be of the form
"NAME arguments").public String extensionParameter(String name)
name
- The name of the target server extension.
public boolean supportsExtension(String name)
name
- The target extension name.
protected boolean supportsAuthentication(String mechanism)
mechanism
- The mechanism name.
protected boolean processAuthentication() throws javax.mail.MessagingException
javax.mail.MessagingException
protected void debugOut(String message)
protected void debugOut(String message, Throwable e)
message
- A message associated with the exception context.e
- The received exception.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |