|
|||||||||
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. To use this class, construct a server with your implementation of the MessageHandlerFactory. This provides low-level callbacks at various phases of the SMTP exchange. For a higher-level but more limited interface, you can pass in a org.subethamail.smtp.helper.SimpleMessageListenerAdapter. By default, no authentication methods are offered. To use authentication, set an AuthenticationHandlerFactory.
Constructor Summary | |
---|---|
SMTPServer(MessageHandlerFactory handlerFactory)
The primary constructor. |
|
SMTPServer(MessageHandlerFactory msgHandlerFact,
AuthenticationHandlerFactory authHandlerFact)
The primary constructor. |
Method Summary | |
---|---|
protected void |
closeServerSocket()
Closes the serverSocket in an orderly way |
protected java.net.ServerSocket |
createServerSocket()
Override this method if you want to create your own server sockets. |
AuthenticationHandlerFactory |
getAuthenticationHandlerFactory()
|
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. |
int |
getConnectionTimeout()
|
boolean |
getHideTLS()
|
java.lang.String |
getHostName()
|
int |
getMaxConnections()
|
int |
getMaxRecipients()
|
MessageHandlerFactory |
getMessageHandlerFactory()
|
java.lang.String |
getName()
|
java.lang.String |
getNameVersion()
|
int |
getNumberOfConnections()
|
int |
getPort()
|
protected java.lang.ThreadGroup |
getSessionGroup()
|
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 |
setAuthenticationHandlerFactory(AuthenticationHandlerFactory fact)
|
void |
setBacklog(int backlog)
The backlog is the Socket backlog. |
void |
setBindAddress(java.net.InetAddress bindAddress)
null means all interfaces |
void |
setConnectionTimeout(int connectionTimeout)
Set the number of milliseconds that the server will wait for client input. |
void |
setHideTLS(boolean value)
If set to true, TLS will not be advertised in the EHLO string. |
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)
Set the maximum number of recipients allowed for each message. |
void |
setMessageHandlerFactory(MessageHandlerFactory fact)
|
void |
setPort(int port)
|
void |
start()
Call this method to get things rolling after instantiating the SMTPServer. |
void |
stop()
Shut things down gracefully. |
protected void |
stopAllSessions()
Grabs all instances of Sessions and attempts to close the socket if it is still open. |
protected void |
stopServerThread()
Shuts down the server thread and the associated server socket in an orderly fashion. |
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(MessageHandlerFactory msgHandlerFact, AuthenticationHandlerFactory authHandlerFact)
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 stopAllSessions()
protected java.net.ServerSocket createServerSocket() throws java.io.IOException
java.io.IOException
protected void closeServerSocket()
protected void stopServerThread()
public void run()
run
in interface java.lang.Runnable
public java.lang.String getName()
public java.lang.String getNameVersion()
public MessageHandlerFactory getMessageHandlerFactory()
public void setMessageHandlerFactory(MessageHandlerFactory fact)
public AuthenticationHandlerFactory getAuthenticationHandlerFactory()
public void setAuthenticationHandlerFactory(AuthenticationHandlerFactory fact)
public CommandHandler getCommandHandler()
protected java.lang.ThreadGroup getSessionGroup()
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)
public boolean getHideTLS()
public void setHideTLS(boolean value)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |