|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectthings.data.transport.smtp.FancySMTPClient
public class FancySMTPClient
This is a fancy SMTP client. It expected the server to supposed extensions
The client will propagate any InterruptedExceptions like a good THINGs citizen, though it will then mark the client as BAD and it will no longer work--through exceptions for any call thereafter.
Version History
EPG - Added by request - 1 JUNV 09
Field Summary | |
---|---|
static int |
CONNECTION_RETRIES
|
static int |
CONNECTION_TIMEOUT
|
static java.lang.String |
EXTENSION_DSN
Extension names. |
Constructor Summary | |
---|---|
FancySMTPClient(Logger theLogger)
Create a new client. |
|
FancySMTPClient(Logger theLogger,
java.lang.String name)
Create a new client with an imposed name. |
Method Summary | |
---|---|
Reply |
connect(java.lang.String connectAddress,
int connectPort)
Start a connection. |
void |
debuggingOff()
Turn debugging off. |
void |
debuggingOn()
Turn debugging on. |
boolean |
debuggingState()
Get the current debugging SMTPSMTPState. |
Reply |
disconnect()
Start a connection. |
Reply |
done()
Quit the client. |
boolean |
extensionPresent(java.lang.String extensionName)
Is a named extension present? |
void |
flush()
Try to flush. |
java.lang.String |
getName()
Get client name. |
SMTPState |
getState()
Get the SMTPState. |
Reply |
login(java.lang.String hostname)
HELO with the hostname--no authentication. |
void |
post(java.lang.String message)
Post as a message. |
void |
postit(java.lang.String message)
Post as a message. |
Reply |
recipient(java.lang.String recipientText)
Set the recipient using RCPT TO. |
Reply |
recipient(java.lang.String recipientText,
DSN dsn)
Set the recipient using RCPT TO. |
Reply |
reset()
RESET the connection. |
Reply |
sendData(java.io.InputStream... ios)
Send DATA. |
Reply |
sender(java.lang.String senderText)
Set the sender using MAIL FROM. |
Reply |
sender(java.lang.String senderText,
DSN dsn)
Set the sender using MAIL FROM. |
void |
setSocketRetries(int retries)
Number of times a socket read will be retried after a timeout before completely giving up. The default value is CONNECTION_RETRIES. |
void |
setTimeout(int timeout)
Set the socket timeout for each connection. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int CONNECTION_TIMEOUT
public static final int CONNECTION_RETRIES
public static final java.lang.String EXTENSION_DSN
Constructor Detail |
---|
public FancySMTPClient(Logger theLogger, java.lang.String name)
theLogger
- the logger to use. It will be quiet unless you start debugging.name
- the client's name. It will be slightly altered for uniqueness.public FancySMTPClient(Logger theLogger)
theLogger
- the logger to use. It will be quiet unless you start debugging.Method Detail |
---|
public java.lang.String getName()
getName
in interface SMTPClient
public SMTPState getState()
getState
in interface SMTPClient
public void setTimeout(int timeout)
It will take effect whenever a new connection is established.
setTimeout
in interface SMTPClient
timeout
- the timeout in milliseconds.public void setSocketRetries(int retries)
It will take effect whenever a new operation is started.
setSocketRetries
in interface SMTPClient
retries
- Number of retries. Zero or a negative number is the same as no retries.public Reply connect(java.lang.String connectAddress, int connectPort) throws ThingsException, java.lang.InterruptedException
connect
in interface SMTPClient
connectAddress
- connectPort
-
ThingsException
- will always be fatal at this point.
java.lang.InterruptedException
public Reply disconnect() throws ThingsException, java.lang.InterruptedException
disconnect
in interface SMTPClient
ThingsException
- which will never happen, since we'll just abandon the bad connection.
java.lang.InterruptedException
public Reply login(java.lang.String hostname) throws ThingsException, java.lang.InterruptedException
login
in interface SMTPClient
hostname
-
ThingsException
java.lang.InterruptedException
public Reply sender(java.lang.String senderText) throws ThingsException, java.lang.InterruptedException
sender
in interface SMTPClient
senderText
- as a valid SMTP address.
ThingsException
- if not ready for MAIL FROM or actual transmission problem.
java.lang.InterruptedException
public Reply sender(java.lang.String senderText, DSN dsn) throws ThingsException, java.lang.InterruptedException
sender
in interface SMTPClient
senderText
- as a valid SMTP address.dsn
- command. If null, it will be ignored.
ThingsException
- if not ready for MAIL FROM or actual transmission problem.
java.lang.InterruptedException
public Reply recipient(java.lang.String recipientText) throws ThingsException, java.lang.InterruptedException
recipient
in interface SMTPClient
recipientText
- as a valid SMTP address.
ThingsException
- if not ready for RCPT TO or actual transmission problem.
java.lang.InterruptedException
public Reply recipient(java.lang.String recipientText, DSN dsn) throws ThingsException, java.lang.InterruptedException
recipient
in interface SMTPClient
recipientText
- as a valid SMTP address.dsn
- command. If null, it will be ignored.
ThingsException
- if not ready for RCPT TO or actual transmission problem.
java.lang.InterruptedException
public Reply reset() throws ThingsException, java.lang.InterruptedException
reset
in interface SMTPClient
ThingsException
- if the connection is made and logged in.
java.lang.InterruptedException
public Reply sendData(java.io.InputStream... ios) throws ThingsException, java.lang.InterruptedException
sendData
in interface SMTPClient
ios
- Stream to send. You handle any buffering. Null entries are allowed and ignored.
ThingsException
java.lang.InterruptedException
public Reply done() throws ThingsException, java.lang.InterruptedException
done
in interface SMTPClient
ThingsException
java.lang.InterruptedException
public boolean extensionPresent(java.lang.String extensionName)
extensionName
-
public void debuggingOn()
debuggingOn
in interface Debuggable
public void debuggingOff()
debuggingOff
in interface Debuggable
public boolean debuggingState()
debuggingState
in interface Debuggable
public void post(java.lang.String message) throws ThingsException
post
in interface StringPoster
message
- String to post
ThingsException
public void postit(java.lang.String message)
postit
in interface StringPoster
message
- String to postpublic void flush()
flush
in interface StringPoster
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |