Package com.dumbster.smtp
Class SimpleSmtpServer
- java.lang.Object
-
- com.dumbster.smtp.SimpleSmtpServer
-
- All Implemented Interfaces:
java.lang.Runnable
public class SimpleSmtpServer extends java.lang.Object implements java.lang.RunnableDummy SMTP server for testing purposes.
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_SMTP_PORTDefault SMTP port is 25.
-
Constructor Summary
Constructors Constructor Description SimpleSmtpServer(int port)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.IteratorgetReceivedEmail()Get email received by this instance since start up.intgetReceivedEmailSize()Get the number of messages received.booleanisStopped()Check if the server has been placed in a stopped state.voidrun()Main loop of the SMTP server.static SimpleSmtpServerstart()Creates an instance of SimpleSmtpServer and starts it.static SimpleSmtpServerstart(int port)Creates an instance of SimpleSmtpServer and starts it.voidstop()Stops the server.
-
-
-
Field Detail
-
DEFAULT_SMTP_PORT
public static final int DEFAULT_SMTP_PORT
Default SMTP port is 25.- See Also:
- Constant Field Values
-
-
Method Detail
-
run
public void run()
Main loop of the SMTP server.- Specified by:
runin interfacejava.lang.Runnable
-
isStopped
public boolean isStopped()
Check if the server has been placed in a stopped state. Allows another thread to stop the server safely.- Returns:
- true if the server has been sent a stop signal, false otherwise
-
stop
public void stop()
Stops the server. Server is shutdown after processing of the current request is complete.
-
getReceivedEmail
public java.util.Iterator getReceivedEmail()
Get email received by this instance since start up.- Returns:
- List of String
-
getReceivedEmailSize
public int getReceivedEmailSize()
Get the number of messages received.- Returns:
- size of received email list
-
start
public static SimpleSmtpServer start()
Creates an instance of SimpleSmtpServer and starts it. Will listen on the default port.- Returns:
- a reference to the SMTP server
-
start
public static SimpleSmtpServer start(int port)
Creates an instance of SimpleSmtpServer and starts it.- Parameters:
port- port number the server should listen to- Returns:
- a reference to the SMTP server
-
-