|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.subethamail.smtp.server.SMTPServer
public class SMTPServer
Main SMTPServer class. Construct this object, set the hostName, port, and bind address if you wish to override the defaults, and call start(). This class starts opens a ServerSocket and creates a new instance of the ConnectionHandler class when a new connection comes in. The ConnectionHandler then parses the incoming SMTP stream and hands off the processing to the CommandHandler which will execute the appropriate SMTP command class. This class also manages a watchdog thread which will timeout stale connections. There are two ways of using this server. The first is to construct with a MessageHandlerFactory. This provides the lowest-level and most flexible access. The second way is to construct with a collection of MessageListeners. This is a higher, and sometimes more convenient level of abstraction. In neither case is the SMTP server (this library) responsible for deciding what recipients to accept or what to do with the incoming data. That is left to you.
Constructor Summary | |
---|---|
SMTPServer(java.util.Collection<MessageListener> listeners)
A convenience constructor that splits the smtp data among multiple listeners (and multiple recipients). |
|
SMTPServer(MessageHandlerFactory handlerFactory)
The primary constructor. |
Method Summary | |
---|---|
protected java.net.ServerSocket |
createServerSocket()
Override this method if you want to create your own server sockets. |
int |
getBacklog()
The backlog is the Socket backlog. |
java.net.InetAddress |
getBindAddress()
null means all interfaces |
CommandHandler |
getCommandHandler()
The CommandHandler manages handling the SMTP commands such as QUIT, MAIL, RCPT, DATA, etc. |
protected java.lang.ThreadGroup |
getConnectionGroup()
|
int |
getConnectionTimeout()
|
java.lang.String |
getHostName()
|
int |
getMaxConnections()
|
int |
getMaxRecipients()
|
MessageHandlerFactory |
getMessageHandlerFactory()
All smtp data is eventually routed through the handlers. |
java.lang.String |
getName()
|
java.lang.String |
getNameVersion()
|
int |
getNumberOfConnections()
|
int |
getPort()
|
boolean |
hasTooManyConnections()
|
boolean |
isRunning()
Is the server running after start() has been called? |
void |
run()
This method is called by this thread when it starts up. |
void |
setBacklog(int backlog)
The backlog is the Socket backlog. |
void |
setBindAddress(java.net.InetAddress bindAddress)
null means all interfaces |
void |
setConnectionTimeout(int connectionTimeout)
|
void |
setHostName(java.lang.String hostName)
The host name that will be reported to SMTP clients |
void |
setMaxConnections(int maxConnections)
Set's the maximum number of connections this server instance will accept. |
void |
setMaxRecipients(int maxRecipients)
|
void |
setPort(int port)
|
protected void |
shutDownOpenConnections()
Grabs all ThreadGroup instances of ConnectionHander's and attempts to close the socket if it is still open. |
void |
start()
Call this method to get things rolling after instantiating the SMTPServer. |
void |
stop()
Shut things down gracefully. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SMTPServer(MessageHandlerFactory handlerFactory)
public SMTPServer(java.util.Collection<MessageListener> listeners)
Method Detail |
---|
public java.lang.String getHostName()
public void setHostName(java.lang.String hostName)
public java.net.InetAddress getBindAddress()
public void setBindAddress(java.net.InetAddress bindAddress)
public int getPort()
public void setPort(int port)
public boolean isRunning()
public int getBacklog()
public void setBacklog(int backlog)
public void start()
public void stop()
protected void shutDownOpenConnections()
protected java.net.ServerSocket createServerSocket() throws java.io.IOException
java.io.IOException
public void run()
run
in interface java.lang.Runnable
public java.lang.String getName()
public java.lang.String getNameVersion()
public MessageHandlerFactory getMessageHandlerFactory()
public CommandHandler getCommandHandler()
protected java.lang.ThreadGroup getConnectionGroup()
public int getNumberOfConnections()
public boolean hasTooManyConnections()
public int getMaxConnections()
public void setMaxConnections(int maxConnections)
maxConnections
- public int getConnectionTimeout()
public void setConnectionTimeout(int connectionTimeout)
public int getMaxRecipients()
public void setMaxRecipients(int maxRecipients)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |