public class AuthenticatingSMTPClient extends SMTPSClient
SMTPClient
Modifier and Type | Class and Description |
---|---|
static class |
AuthenticatingSMTPClient.AUTH_METHOD
The enumeration of currently-supported authentication methods.
|
_commandSupport_, DEFAULT_PORT, encoding
_defaultPort_, _hostname_, _input_, _output_, _serverSocketFactory_, _socket_, _socketFactory_, _timeout_, connectTimeout, NETASCII_EOL
Constructor and Description |
---|
AuthenticatingSMTPClient()
The default AuthenticatingSMTPClient constructor.
|
AuthenticatingSMTPClient(boolean implicit,
SSLContext ctx)
Overloaded constructor that takes the implicit argument, and using
SMTPSClient.DEFAULT_PROTOCOL i.e. |
AuthenticatingSMTPClient(String protocol)
Overloaded constructor that takes a protocol specification
|
AuthenticatingSMTPClient(String proto,
boolean implicit)
Overloaded constructor that takes a protocol specification and the implicit argument
|
AuthenticatingSMTPClient(String proto,
boolean implicit,
String encoding)
Overloaded constructor that takes the protocol specification, the implicit argument and encoding
|
AuthenticatingSMTPClient(String protocol,
String encoding)
Overloaded constructor that takes a protocol specification and encoding
|
Modifier and Type | Method and Description |
---|---|
boolean |
auth(AuthenticatingSMTPClient.AUTH_METHOD method,
String username,
String password)
Authenticate to the SMTP server by sending the AUTH command with the
selected mechanism, using the given username and the given password.
|
int |
ehlo(String hostname)
A convenience method to send the ESMTP EHLO command to the server,
receive the reply, and return the reply code.
|
boolean |
elogin()
Login to the ESMTP server by sending the EHLO command with the
client hostname as an argument.
|
boolean |
elogin(String hostname)
Login to the ESMTP server by sending the EHLO command with the
given hostname as an argument.
|
int[] |
getEnhancedReplyCode()
Returns the integer values of the enhanced reply code of the last SMTP reply.
|
_connectAction_, execTLS, getEnabledCipherSuites, getEnabledProtocols, getHostnameVerifier, getKeyManager, getTrustManager, isEndpointCheckingEnabled, setEnabledCipherSuites, setEnabledProtocols, setEndpointCheckingEnabled, setHostnameVerifier, setKeyManager, setTrustManager
addRecipient, addRecipient, completePendingCommand, listHelp, listHelp, login, login, logout, reset, sendMessageData, sendNoOp, sendShortMessageData, sendSimpleMessage, sendSimpleMessage, setSender, setSender, verify
data, disconnect, expn, getCommandSupport, getReply, getReplyCode, getReplyString, getReplyStrings, helo, help, help, mail, noop, quit, rcpt, removeProtocolCommandistener, rset, saml, send, sendCommand, sendCommand, sendCommand, sendCommand, soml, turn, vrfy
addProtocolCommandListener, connect, connect, connect, connect, connect, connect, createCommandSupport, fireCommandSent, fireReplyReceived, getCharset, getCharsetName, getConnectTimeout, getDefaultPort, getDefaultTimeout, getKeepAlive, getLocalAddress, getLocalPort, getProxy, getReceiveBufferSize, getRemoteAddress, getRemotePort, getSendBufferSize, getServerSocketFactory, getSoLinger, getSoTimeout, getTcpNoDelay, isAvailable, isConnected, removeProtocolCommandListener, setCharset, setConnectTimeout, setDefaultPort, setDefaultTimeout, setKeepAlive, setProxy, setReceiveBufferSize, setSendBufferSize, setServerSocketFactory, setSocketFactory, setSoLinger, setSoTimeout, setTcpNoDelay, verifyRemote
public AuthenticatingSMTPClient()
public AuthenticatingSMTPClient(String protocol)
protocol
- The protocol to usepublic AuthenticatingSMTPClient(String proto, boolean implicit)
proto
- the protocol.implicit
- The security mode, true
for implicit, false
for explicitpublic AuthenticatingSMTPClient(String proto, boolean implicit, String encoding)
proto
- the protocol.implicit
- The security mode, true
for implicit, false
for explicitencoding
- the encodingpublic AuthenticatingSMTPClient(boolean implicit, SSLContext ctx)
SMTPSClient.DEFAULT_PROTOCOL
i.e. TLSimplicit
- The security mode, true
for implicit, false
for explicitctx
- A pre-configured SSL Context.public AuthenticatingSMTPClient(String protocol, String encoding)
protocol
- The protocol to useencoding
- The encoding to usepublic int ehlo(String hostname) throws IOException
hostname
- The hostname of the sender.SMTPConnectionClosedException
- If the SMTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send SMTP reply code 421. This exception may be caught either
as an IOException or independently as itself.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public boolean elogin(String hostname) throws IOException
hostname
- The hostname with which to greet the SMTP server.SMTPConnectionClosedException
- If the SMTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send SMTP reply code 421. This exception may be caught either
as an IOException or independently as itself.IOException
- If an I/O error occurs while either sending a
command to the server or receiving a reply from the server.public boolean elogin() throws IOException
SMTPConnectionClosedException
- If the SMTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send SMTP reply code 421. This exception may be caught either
as an IOException or independently as itself.IOException
- If an I/O error occurs while either sending a
command to the server or receiving a reply from the server.public int[] getEnhancedReplyCode()
public boolean auth(AuthenticatingSMTPClient.AUTH_METHOD method, String username, String password) throws IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidKeySpecException
method
- the method to use, one of the AuthenticatingSMTPClient.AUTH_METHOD
enum valuesusername
- the user name.
If the method is XOAUTH, then this is used as the plain text oauth protocol parameter string
which is Base64-encoded for transmission.password
- the password for the username.
Ignored for XOAUTH.SMTPConnectionClosedException
- If the SMTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send SMTP reply code 421. This exception may be caught either
as an IOException or independently as itself.IOException
- If an I/O error occurs while either sending a
command to the server or receiving a reply from the server.NoSuchAlgorithmException
- If the CRAM hash algorithm
cannot be instantiated by the Java runtime system.InvalidKeyException
- If the CRAM hash algorithm
failed to use the given password.InvalidKeySpecException
- If the CRAM hash algorithm
failed to use the given password.Copyright © 2001–2016 The Apache Software Foundation. All rights reserved.