org.subethamail.wiser
Class Wiser

java.lang.Object
  extended by org.subethamail.wiser.Wiser
All Implemented Interfaces:
MessageListener

public class Wiser
extends java.lang.Object
implements MessageListener

Wiser is a smart mail testing application.

Author:
Jon Stevens, De Oliveira Edouard <doe_wanted@yahoo.fr>

Nested Class Summary
 class Wiser.AuthHandlerFactory
          Creates the AuthHandlerFactory which logs the user/pass.
 
Constructor Summary
Wiser()
          Create a new SMTP server with this class as the listener.
 
Method Summary
 boolean accept(java.lang.String from, java.lang.String recipient)
          Always accept everything
 void deliver(java.lang.String from, java.lang.String recipient, java.io.InputStream data)
          Cache the messages in memory.
 java.util.List<WiserMessage> getMessages()
           
 SMTPServer getServer()
           
protected  javax.mail.Session getSession()
          Creates the JavaMail Session object for use in WiserMessage
static void main(java.lang.String[] args)
          A main() for this class.
 void setDataDeferredSize(int dataDeferredSize)
          Set the size at which the mail will be temporary stored on disk.
 void setHostname(java.lang.String hostname)
          The hostname that the server should listen on.
 void setPort(int port)
          The port that the server should listen on.
 void setReceiveBufferSize(int size)
          Set the receive buffer size.
 void start()
          Starts the SMTP Server
 void stop()
          Stops the SMTP Server
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Wiser

public Wiser()
Create a new SMTP server with this class as the listener. The default port is set to 25. Call setPort()/setHostname() before calling start().

Method Detail

setPort

public void setPort(int port)
The port that the server should listen on.

Parameters:
port -

setDataDeferredSize

public void setDataDeferredSize(int dataDeferredSize)
Set the size at which the mail will be temporary stored on disk.

Parameters:
dataDeferredSize -

setReceiveBufferSize

public void setReceiveBufferSize(int size)
Set the receive buffer size.

Parameters:
size -

setHostname

public void setHostname(java.lang.String hostname)
The hostname that the server should listen on.

Parameters:
hostname -

start

public void start()
Starts the SMTP Server


stop

public void stop()
Stops the SMTP Server


main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
A main() for this class. Starts up the server.

Throws:
java.lang.Exception

accept

public boolean accept(java.lang.String from,
                      java.lang.String recipient)
Always accept everything

Specified by:
accept in interface MessageListener
Parameters:
from - is a rfc822-compliant email address.
recipient - is a rfc822-compliant email address.
Returns:
true if the listener wants delivery of the message, false if the message is not for this listener.

deliver

public void deliver(java.lang.String from,
                    java.lang.String recipient,
                    java.io.InputStream data)
             throws TooMuchDataException,
                    java.io.IOException
Cache the messages in memory. Now avoids unnecessary memory copying.

Specified by:
deliver in interface MessageListener
Parameters:
from - is the envelope sender in rfc822 form
recipient - will be an accepted recipient in rfc822 form
data - will be the smtp data stream, stripped of any extra '.' chars
Throws:
TooMuchDataException - if the listener can't handle that much data. An error will be reported to the client.
java.io.IOException - if there is an IO error reading the input data.

getSession

protected javax.mail.Session getSession()
Creates the JavaMail Session object for use in WiserMessage


getMessages

public java.util.List<WiserMessage> getMessages()
Returns:
the list of WiserMessages

getServer

public SMTPServer getServer()
Returns:
an instance of the SMTPServer object


Copyright © 2011 SubEthaSMTP. All Rights Reserved. Build version: UNVERSIONED