|
||||||||||
| 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)
Simple constructor. |
|
SMTPServer(MessageHandlerFactory handlerFactory,
AuthenticationHandlerFactory authHandlerFact)
Constructor with AuthenticationHandlerFactory. |
|
SMTPServer(MessageHandlerFactory msgHandlerFact,
AuthenticationHandlerFactory authHandlerFact,
ExecutorService executorService)
Complex constructor. |
|
| Method Summary | |
|---|---|
protected ServerSocket |
createServerSocket()
Override this method if you want to create your own server sockets. |
SSLSocket |
createSSLSocket(Socket socket)
Create a SSL socket that wraps the existing socket. |
AuthenticationHandlerFactory |
getAuthenticationHandlerFactory()
|
int |
getBacklog()
The backlog is the Socket backlog. |
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 |
getDisableReceivedHeaders()
|
boolean |
getDisableTLS()
Deprecated. use enableTLS |
String |
getDisplayableLocalSocketAddress()
|
boolean |
getEnableTLS()
|
ExecutorService |
getExecutorService()
|
boolean |
getHideTLS()
|
String |
getHostName()
|
int |
getMaxConnections()
|
int |
getMaxMessageSize()
|
int |
getMaxRecipients()
|
MessageHandlerFactory |
getMessageHandlerFactory()
|
int |
getPort()
|
boolean |
getRequireTLS()
|
SessionIdFactory |
getSessionIdFactory()
|
String |
getSoftwareName()
The string reported to the public as the software running here. |
boolean |
isRunning()
Is the server running after start() has been called? |
void |
setAuthenticationHandlerFactory(AuthenticationHandlerFactory fact)
|
void |
setBacklog(int backlog)
The backlog is the Socket backlog. |
void |
setBindAddress(InetAddress bindAddress)
null means all interfaces |
void |
setConnectionTimeout(int connectionTimeout)
Set the number of milliseconds that the server will wait for client input. |
void |
setDisableReceivedHeaders(boolean disableReceivedHeaders)
|
void |
setDisableTLS(boolean value)
Deprecated. use setEnableTLS(boolean) |
void |
setEnableTLS(boolean enableTLS)
If set to true, TLS will be supported. |
void |
setHideTLS(boolean value)
If set to true, TLS will not be advertised in the EHLO string. |
void |
setHostName(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 |
setSessionIdFactory(SessionIdFactory sessionIdFactory)
Sets the SessionIdFactory which will allocate a unique identifier
for each mail sessions. |
void |
setSoftwareName(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. |
| 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 handlerFactory,
AuthenticationHandlerFactory authHandlerFact)
AuthenticationHandlerFactory.
public SMTPServer(MessageHandlerFactory msgHandlerFact,
AuthenticationHandlerFactory authHandlerFact,
ExecutorService executorService)
authHandlerFact - the AuthenticationHandlerFactory which performs
authentication in the SMTP AUTH command. If null,
authentication is not supported. Note that setting an
authentication handler does not enforce authentication, it
only makes authentication possible. Enforcing authentication
is the responsibility of the client application, which usually
enforces it only selectively. Use
Session.isAuthenticated() to check whether the client
was authenticated in the session.executorService - the ExecutorService which will handle client connections, one
task per connection. The SMTPServer will shut down this
ExecutorService when the SMTPServer itself stops. If null, a
default one is created by Executors.newCachedThreadPool().| Method Detail |
|---|
public String getHostName()
public void setHostName(String hostName)
public InetAddress getBindAddress()
public void setBindAddress(InetAddress bindAddress)
public int getPort()
public void setPort(int port)
public String getSoftwareName()
public void setSoftwareName(String value)
public ExecutorService getExecutorService()
public boolean isRunning()
public int getBacklog()
public void setBacklog(int backlog)
public void start()
public void stop()
protected ServerSocket createServerSocket()
throws IOException
IOException
public SSLSocket createSSLSocket(Socket socket)
throws 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)
IOException - when creating the socket failedpublic String getDisplayableLocalSocketAddress()
public MessageHandlerFactory getMessageHandlerFactory()
public void setMessageHandlerFactory(MessageHandlerFactory fact)
public AuthenticationHandlerFactory getAuthenticationHandlerFactory()
public void setAuthenticationHandlerFactory(AuthenticationHandlerFactory fact)
public CommandHandler getCommandHandler()
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 void setEnableTLS(boolean enableTLS)
The minimal JSSE configuration necessary for a working TLS support on Oracle JRE 6:
Up to SubEthaSMTP 3.1.5 the default was true, i.e. TLS was enabled.
public boolean getEnableTLS()
@Deprecated public boolean getDisableTLS()
enableTLS
@Deprecated public void setDisableTLS(boolean value)
setEnableTLS(boolean)
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 setpublic boolean getDisableReceivedHeaders()
public void setDisableReceivedHeaders(boolean disableReceivedHeaders)
disableReceivedHeaders - false to include Received headers. Default is false.public SessionIdFactory getSessionIdFactory()
public void setSessionIdFactory(SessionIdFactory sessionIdFactory)
SessionIdFactory which will allocate a unique identifier
for each mail sessions. If not set, a reasonable default will be used.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||