public class SmartClient extends Object
| Modifier | Constructor and Description |
|---|---|
protected |
SmartClient(SMTPClient client,
String clientHeloHost,
Optional<Authenticator> authenticator)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
bdat(String text) |
void |
bdat(String text,
boolean isLast) |
void |
bdatLast(String text) |
void |
connect(String host,
int port)
Connects to the specified server and issues the initial HELO command.
|
static SmartClient |
createAndConnect(String host,
int port,
Optional<SocketAddress> bindpoint,
String clientHeloHost,
Optional<Authenticator> authenticator) |
static SmartClient |
createAndConnect(String host,
int port,
String clientHeloHost) |
void |
dataEnd()
Last step after writing data
|
void |
dataStart()
Prelude to writing data
|
void |
dataWrite(byte[] data) |
void |
dataWrite(byte[] data,
int numBytes)
Actually write some data
|
void |
from(String from) |
Optional<Authenticator> |
getAuthenticator()
Returns the Authenticator object, which is used to authenticate this
client to the server, or null, if no authentication is required.
|
Map<String,String> |
getExtensions()
Returns the SMTP extensions supported by the server.
|
String |
getHeloHost()
Returns the HELO name of this system.
|
int |
getRecipientCount() |
void |
quit()
Quit and close down the connection.
|
protected SMTPClient.Response |
receive()
Returns the server response.
|
void |
sendAndCheck(String msg) |
protected void |
sendHeloOrEhlo()
Sends the EHLO command, or HELO if EHLO is not supported, and saves the
list of SMTP extensions which are supported by the server.
|
void |
to(String to) |
protected SmartClient(SMTPClient client, String clientHeloHost, Optional<Authenticator> authenticator)
client - clientHeloHost - authenticator - the Authenticator object which will be called after the EHLO
command to authenticate this client to the server. If is null
then no authentication will happen.public static final SmartClient createAndConnect(String host, int port, String clientHeloHost) throws UnknownHostException, SMTPException, IOException
public static final SmartClient createAndConnect(String host, int port, Optional<SocketAddress> bindpoint, String clientHeloHost, Optional<Authenticator> authenticator) throws UnknownHostException, SMTPException, IOException
public void connect(String host, int port) throws SMTPException, AuthenticationNotSupportedException, IOException
protected void sendHeloOrEhlo()
throws IOException,
SMTPException
IOExceptionSMTPExceptionprotected SMTPClient.Response receive() throws IOException
IOExceptionpublic void from(String from) throws IOException, SMTPException
IOExceptionSMTPExceptionpublic void to(String to) throws IOException, SMTPException
IOExceptionSMTPExceptionpublic void dataStart()
throws IOException,
SMTPException
IOExceptionSMTPExceptionpublic void bdat(String text, boolean isLast) throws IOException
IOExceptionpublic void bdat(String text) throws IOException
IOExceptionpublic void bdatLast(String text) throws IOException
IOExceptionpublic void dataWrite(byte[] data,
int numBytes)
throws IOException
IOExceptionpublic void dataWrite(byte[] data)
throws IOException
IOExceptionpublic void dataEnd()
throws IOException,
SMTPException
IOExceptionSMTPExceptionpublic void quit()
It still closes the connection, but it does not send the QUIT command if a 421 Service closing transmission channel is received previously. In these cases QUIT would fail anyway.
public int getRecipientCount()
public Map<String,String> getExtensions()
public String getHeloHost()
public Optional<Authenticator> getAuthenticator()
public void sendAndCheck(String msg) throws SMTPException, IOException
SMTPExceptionIOExceptionCopyright © 2006–2024. All rights reserved.