See the com.sun.mail.smtp package documentation for further information on the SMTP protocol provider.
This class includes many protected methods that allow a subclass to
extend this class and add support for non-standard SMTP commands.
The issueCommand and sendCommand methods can be
used to send simple SMTP commands. Other methods such as the
mailFrom and data methods can be overridden to
insert new commands before or after the corresponding SMTP commands.
For example, a subclass could do this to send the XACT command
before sending the DATA command:
protected OutputStream data() throws MessagingException {
if (supportsExtension("XACCOUNTING"))
issueCommand("XACT", 25);
return super.data();
}
javax.mail.event.ConnectionEvent, javax.mail.event.TransportEvent
| Modifier and Type | Class and Description |
|---|---|
| private abstract class | SMTPTransport.Authenticator
Abstract base class for SMTP authentication mechanism implementations. |
| private class | SMTPTransport.BDATOutputStream
An SMTPOutputStream that wraps a ChunkedOutputStream. |
| private class | SMTPTransport.ChunkedOutputStream
An OutputStream that buffers data in chunks and uses the RFC 3030 BDAT SMTP command to send each chunk. |
| private class | SMTPTransport.DigestMD5Authenticator
Perform the authentication handshake for DIGEST-MD5 authentication. |
| private class | SMTPTransport.LoginAuthenticator
Perform the authentication handshake for LOGIN authentication. |
| private class | SMTPTransport.NtlmAuthenticator
Perform the authentication handshake for NTLM authentication. |
| private class | SMTPTransport.OAuth2Authenticator
Perform the authentication handshake for XOAUTH2 authentication. |
| private class | SMTPTransport.PlainAuthenticator
Perform the authentication handshake for PLAIN authentication. |
| Modifier and Type | Field and Description |
|---|---|
| private Address[] | |
| private boolean | |
| private Map | |
| private String | |
| private int | |
| private static final byte[] | |
| private SMTPOutputStream | |
| private boolean | |
| private boolean | |
| private String | |
| private int | |
| private boolean | |
| private MessagingException | |
| private Hashtable | |
| private static char[] | |
| private String | |
| private static final String[] | ignoreList
Headers that should not be included when sending |
| private Address[] | |
| private boolean | |
| private int | |
| private String | |
| private LineInputStream | |
| private String | |
| private MailLogger | |
| private MimeMessage | |
| private String | |
| private boolean | |
| private boolean | |
| private boolean | |
| private String | |
| private boolean | |
| private boolean | |
| private boolean | |
| private SaslAuthenticator | |
| private String[] | |
| private String | |
| private boolean | |
| private BufferedInputStream | |
| private OutputStream | |
| private Socket | |
| private TraceInputStream | |
| private MailLogger | |
| private TraceOutputStream | |
| private static final String | |
| private static final String[] | |
| private boolean | |
| private boolean | |
| private boolean | |
| private Address[] | |
| private Address[] |
| Access | Constructor and Description |
|---|---|
| public | SMTPTransport(Session
the Session session, URLName the URLName of this transport urlname)Constructor that takes a Session object and a URLName that represents a specific SMTP server. |
| protected | SMTPTransport(Session
the Session session, URLName the URLName of this transport urlname, String the protocol name of this transport name, boolean use SSL to connect? isSSL)Constructor used by this class and by SMTPSSLTransport subclass. |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| private boolean | |
| protected OutputStream | Returns: the stream to write toReturn a stream that will use the SMTP BDAT command to send data. |
| protected void | |
| public synchronized void | close()
Overrides javax. Implements java. |
| private void | |
| public synchronized void | |
| private boolean | Returns: true if any changes were made XXX - This is really quite a hack.If the Part is a text part and has a Content-Transfer-Encoding of "quoted-printable" or "base64", and it obeys the rules for "8bit" encoding, change the encoding to "8bit". |
| protected OutputStream | Returns: the stream to write toSend the |
| protected boolean | |
| private void | |
| protected void | finalize()
Overrides javax. |
| protected void | |
| protected void | |
| public synchronized String | Returns: the authorization ID to use for authentication.Gets the authorization ID to be used for authentication. |
| public String | Returns: the extension parameterthe service extension name ext)Return the parameter the server provided for the specified service extension, or null if the extension isn't supported. |
| public synchronized int | Returns: return code from last response from serverReturn the return code from the last response we got from the server. |
| public synchronized String | Returns: last response from serverReturn the last response we got from the server. |
| public synchronized String | Returns: the local host nameGet the name of the local host, for use in the EHLO and HELO commands. |
| public synchronized boolean | Returns: true if NOOP must return 250Is the NOOP command required to return a response code of 250 to indicate success? |
| public synchronized String | Returns: the name of the domain to use for NTLM authentication.Gets the NTLM domain to be used for NTLM authentication. |
| public synchronized boolean | Returns: true if an exception will be thrown on successful sends.Should we report even successful sends by throwing an exception? |
| public synchronized boolean | Returns: true if the STARTTLS command will be requiredShould we require the STARTTLS command to secure the connection? |
| public synchronized boolean | |
| public synchronized String[] | Returns: the array of SASL mechanisms to considerGet the list of SASL mechanisms to consider if SASL authentication is enabled. |
| public synchronized String | Returns: the name of the realm to use for SASL authentication.Gets the SASL realm to be used for DIGEST-MD5 authentication. |
| public synchronized boolean | Returns: true if the STARTTLS command will be usedShould we use the STARTTLS command to secure the connection if the server supports it? |
| public synchronized boolean | Returns: true if SASL should use the canonical host nameShould SASL use the canonical host name? |
| public synchronized boolean | Returns: true if RSET will be usedShould we use the RSET command instead of the NOOP command in the @{link #isConnected isConnected} method? |
| protected void | |
| private void | |
| private boolean | is8Bit(InputStream is)
Check whether the data in the given InputStream follows the rules for 8bit text. |
| public synchronized boolean | |
| private boolean | |
| public synchronized boolean | |
| public synchronized void | issueCommand(String
the command to send cmd, int the expected response code (-1 means don't care) expect)Send the command to the server. |
| private void | |
| private boolean | |
| protected void | |
| private String | |
| protected void | notifyTransportListeners(int
the TransportEvent type type, Address[] valid addresses to which message was sent validSent, Address[] valid addresses to which message was not sent validUnsent, Address[] the invalid addresses invalid, Message the message msg)
Notify all TransportListeners.
|
| private void | |
| private void | openServer()
Start the protocol to the server on serverSocket, assumed to be provided and connected by the caller. |
| protected synchronized boolean | Returns: true if connection successful, false if authentication failedthe name of the host to connect to host, int the port to use (-1 means use default port) port, String the name of the user to login as user, String the user's password password)Overrides javax. |
| protected void | rcptTo()
Sends each address to the SMTP host using the |
| protected int | Returns: server response codeReads server reponse returning the |
| private void | |
| private boolean | |
| protected void | |
| private void | |
| public synchronized void | sendMessage(Message
The MimeMessage to be sent message, Address[] List of addresses to send this message to addresses)Implements abstract javax. |
| private void | |
| private void | |
| public synchronized void | setAuthorizationID(String
the authorization ID to use for
authentication. authzid)Sets the authorization ID to be used for authentication. |
| public synchronized void | setLocalHost(String
the local host name localhost)Set the name of the local host, for use in the EHLO and HELO commands. |
| public synchronized void | setNoopStrict(boolean
is NOOP required to return 250? noopStrict)Set whether the NOOP command is required to return a response code of 250 to indicate success. |
| public synchronized void | setNTLMDomain(String
the name of the domain to use for
NTLM authentication. ntlmDomain)Sets the NTLM domain to be used for NTLM authentication. |
| public synchronized void | setReportSuccess(boolean
should we throw an exception on success? reportSuccess)Set whether successful sends should be reported by throwing an exception. |
| public synchronized void | setRequireStartTLS(boolean
should we require the STARTTLS command? requireStartTLS)Set whether the STARTTLS command should be required. |
| public synchronized void | setSASLEnabled(boolean
should we enable SASL authentication? enableSASL)Set whether SASL authentication is enabled. |
| public synchronized void | setSASLMechanisms(String[]
the array of SASL mechanisms to consider mechanisms)Set the list of SASL mechanisms to consider if SASL authentication is enabled. |
| public synchronized void | setSASLRealm(String
the name of the realm to use for
SASL authentication. saslRealm)Sets the SASL realm to be used for DIGEST-MD5 authentication. |
| public synchronized void | setStartTLS(boolean
should we use the STARTTLS command? useStartTLS)Set whether the STARTTLS command should be used. |
| public synchronized void | setUseCanonicalHostName(boolean
should SASL use the canonical host name? useCanonicalHostName)Set whether SASL should use the canonical host name. |
| public synchronized void | setUseRset(boolean
should we use the RSET command? useRset)Set whether the RSET command should be used instead of the NOOP command in the @{link #isConnected isConnected} method. |
| public synchronized int | Returns: the response codethe command cmd)Send the command to the server and return the response code from the server. |
| protected int | Returns: the response codethe command cmd)Send the command to the server and return the response code from the server. |
| protected void | |
| protected boolean | Returns: true if the authentication mechanism is supportedthe authentication mechanism auth)Does the server we're connected to support the specified authentication mechanism? |
| public boolean | Returns: true if the extension is supportedthe service extension name ext)Return true if the SMTP server supports the specified service extension. |
| private void | suspendTracing()
Temporarily turn off protocol tracing, e.g., to prevent tracing the authentication sequence, including the password. |
| private byte[] | |
| private String | |
| private String | |
| protected static String | |
| protected static String |