|
||||||||||
| 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. |
javax.net.ssl.SSLSocket |
createSSLSocket(java.net.Socket socket)
Create a SSL socket that wraps the existing socket. |
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 |
getDisableTLS()
|
boolean |
getHideTLS()
|
java.lang.String |
getHostName()
|
int |
getMaxConnections()
|
int |
getMaxMessageSize()
|
int |
getMaxRecipients()
|
MessageHandlerFactory |
getMessageHandlerFactory()
|
int |
getNumberOfConnections()
|
int |
getPort()
|
boolean |
getRequireTLS()
|
protected java.lang.ThreadGroup |
getSessionGroup()
|
java.lang.String |
getSoftwareName()
The string reported to the public as the software running here. |
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 |
setDisableTLS(boolean value)
If set to true, TLS will not be announced or supported. |
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 |
setMaxMessageSize(int maxMessageSize)
|
void |
setMaxRecipients(int maxRecipients)
Set the maximum number of recipients allowed for each message. |
void |
setMessageHandlerFactory(MessageHandlerFactory fact)
|
void |
setPort(int port)
|
void |
setRequireTLS(boolean requireTLS)
|
void |
setSoftwareName(java.lang.String value)
Changes the publicly reported software information. |
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 java.lang.String getSoftwareName()
public void setSoftwareName(java.lang.String value)
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.IOExceptionprotected void closeServerSocket()
public javax.net.ssl.SSLSocket createSSLSocket(java.net.Socket socket)
throws java.io.IOException
Subclasses may override this method to configure the key stores, enabled protocols/ cipher suites, enforce client authentication, etc.
socket - the existing socket as created by createServerSocket() (not null)
java.io.IOException - when creating the socket failedprotected void stopServerThread()
public void run()
run in interface java.lang.Runnablepublic 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 getDisableTLS()
public void setDisableTLS(boolean value)
public boolean getHideTLS()
public void setHideTLS(boolean value)
public boolean getRequireTLS()
public void setRequireTLS(boolean requireTLS)
requireTLS - true to require a TLS handshake,
false to allow operation with or without TLS.
Default is false; ignored when disableTLS=true.public int getMaxMessageSize()
public void setMaxMessageSize(int maxMessageSize)
maxMessageSize - the maxMessageSize to set
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||