|
|||||||||
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 Mina based listener 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. 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.
Field Summary | |
---|---|
static java.nio.charset.Charset |
DEFAULT_CHARSET
|
protected static int |
DEFAULT_DATA_DEFERRED_SIZE
4 megs by default. |
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 | |
---|---|
boolean |
announceTLS()
|
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()
What is the connection timeout? |
int |
getDataDeferredSize()
Get the maximum size in bytes of a single message before it is dumped to a temporary file. |
java.lang.String |
getHostName()
|
int |
getMaxConnections()
What is the maximum amount of connections? |
int |
getMaxRecipients()
What is the maximum number of recipients for a single message ? |
MessageHandlerFactory |
getMessageHandlerFactory()
All smtp data is eventually routed through the handlers. |
java.lang.String |
getName()
The name of the server software. |
java.lang.String |
getNameVersion()
The name + version of the server software. |
int |
getNumberOfConnections()
Number of connections in the handler. |
int |
getPort()
get the port the server is running on. |
boolean |
hasTooManyConnections()
Are we over the maximum amount of connections ? |
protected boolean |
isPowerOfTwo(int x)
Demonstration : if x is a power of 2, it can't share any bit with x-1. |
boolean |
isRunning()
Is the server running after start() has been called? |
void |
setAnnounceTLS(boolean announceTls)
Tells the server to announce the TLS support. |
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 connection timeout. |
void |
setDataDeferredSize(int dataDeferredSize)
Set the maximum size in bytes of a single message before it is dumped to a temporary file. |
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 for a single message. |
void |
setPort(int port)
set the port the server is running on. |
void |
setReceiveBufferSize(int receiveBufferSize)
Sets the receive buffer size. |
void |
start()
Call this method to get things rolling after instantiating the SMTPServer. |
void |
startJMXService()
Starts the JMX service with a polling interval default of 1000ms. |
void |
startJMXService(int pollingInterval)
Start the JMX service. |
void |
stop()
Shut things down gracefully. |
void |
stopJMXService()
Stop the JMX service. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.nio.charset.Charset DEFAULT_CHARSET
protected static final int DEFAULT_DATA_DEFERRED_SIZE
Constructor Detail |
---|
public SMTPServer(MessageHandlerFactory handlerFactory)
public SMTPServer(java.util.Collection<MessageListener> listeners)
Method Detail |
---|
public void startJMXService() throws javax.management.InstanceAlreadyExistsException, javax.management.MBeanRegistrationException, javax.management.NotCompliantMBeanException
javax.management.InstanceAlreadyExistsException
javax.management.MBeanRegistrationException
javax.management.NotCompliantMBeanException
public void startJMXService(int pollingInterval) throws javax.management.InstanceAlreadyExistsException, javax.management.MBeanRegistrationException, javax.management.NotCompliantMBeanException
pollingInterval
-
javax.management.InstanceAlreadyExistsException
javax.management.MBeanRegistrationException
javax.management.NotCompliantMBeanException
public void stopJMXService() throws javax.management.InstanceNotFoundException, javax.management.MBeanRegistrationException
javax.management.InstanceNotFoundException
javax.management.MBeanRegistrationException
public void start()
public void stop()
public void setAnnounceTLS(boolean announceTls)
public boolean announceTLS()
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)
port
- public boolean isRunning()
public int getBacklog()
public void setBacklog(int backlog)
public java.lang.String getName()
public java.lang.String getNameVersion()
public MessageHandlerFactory getMessageHandlerFactory()
public CommandHandler getCommandHandler()
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 int getDataDeferredSize()
public void setDataDeferredSize(int dataDeferredSize)
ByteBuffer
to prevent unnecessary
memory consumption.
public void setReceiveBufferSize(int receiveBufferSize)
protected boolean isPowerOfTwo(int x)
x
- the number to test
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |