Package com.icegreen.greenmail.util
Class ServerSetup
java.lang.Object
com.icegreen.greenmail.util.ServerSetup
Defines the default ports
Use
| smtp | 25 |
| smtps | 465 |
| pop3 | 110 |
| pop3s | 995 |
| imap | 143 |
| imaps | 993 |
ServerSetupTest for non-default ports
- Since:
- Jan 28, 2006
Use
ServerSetupTestfor non-default ports - Author:
- Wael Chatila
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ServerSetup[]static final longDefault socket connection timeout.static final ServerSetupstatic final ServerSetupstatic final ServerSetupstatic final ServerSetupstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String[]static final longDefault socket read timeout.static final longDefault server startup timeout in milliseconds.static final ServerSetupstatic final ServerSetup[]static final ServerSetup[]static final ServerSetup[]static final ServerSetupstatic final ServerSetup[]static final ServerSetup[]static final ServerSetup[] -
Constructor Summary
ConstructorsConstructorDescriptionServerSetup(int port, String bindAddress, String protocol) Creates a configuration. -
Method Summary
Modifier and TypeMethodDescriptionconfigureJavaMailSessionProperties(Properties properties, boolean debug) Creates default properties for a JavaMail session.Create a deep copy.createCopy(int port, String bindAddress, String protocol) Create a deep copy.static ServerSetup[]createCopy(ServerSetup[] serverSetups, UnaryOperator<ServerSetup> copyMutator) Creates a copy applying given mutator on each copy.createCopy(String bindAddress) Create a deep copy.Enable dynamic port allocation.static ServerSetup[]dynamicPort(ServerSetup[] serverSetups) Creates a copy with dynamic ports (auto-detecting available ports) enabled.booleanlongGets the public default host address "0.0.0.0".static StringintgetPort()longlonglonginthashCode()booleanTrue if available port gets dynamically allocated.booleanisSecure()booleanstatic ServerSetup[]mailSessionProperty(ServerSetup[] serverSetups, String key, String value) Creates a copy with configured default mail session property.mailSessionProperty(String key, String value) Create a new server setup copy, configured with given JavaMail session property.port(int port) Creates a deep copy and updates port.voidsetConnectionTimeout(long connectionTimeout) voidsetReadTimeout(long readTimeout) voidsetServerStartupTimeout(long timeoutInMs) Sets the server startup timeout in milliseconds.setVerbose(boolean verbose) voidsetWriteTimeout(long writeTimeout) toString()verbose(boolean verbose) Creates a deep copy with verbose configured.static ServerSetup[]verbose(ServerSetup[] serverSetups) Creates a copy with verbose mode enabled.withPort(int port) Deprecated.
-
Field Details
-
PROTOCOL_SMTP
- See Also:
-
PROTOCOL_SMTPS
- See Also:
-
PROTOCOL_POP3
- See Also:
-
PROTOCOL_POP3S
- See Also:
-
PROTOCOL_IMAP
- See Also:
-
PROTOCOL_IMAPS
- See Also:
-
PROTOCOLS
-
PORT_SMTP
public static final int PORT_SMTP- See Also:
-
PORT_SMTPS
public static final int PORT_SMTPS- See Also:
-
PORT_POP3
public static final int PORT_POP3- See Also:
-
PORT_POP3S
public static final int PORT_POP3S- See Also:
-
PORT_IMAP
public static final int PORT_IMAP- See Also:
-
PORT_IMAPS
public static final int PORT_IMAPS- See Also:
-
SMTP
-
SMTPS
-
POP3
-
POP3S
-
IMAP
-
IMAPS
-
SMTP_POP3
-
SMTP_IMAP
-
SMTP_POP3_IMAP
-
SMTPS_POP3S
-
SMTPS_POP3S_IMAPS
-
SMTPS_IMAPS
-
ALL
-
READ_TIMEOUT
public static final long READ_TIMEOUTDefault socket read timeout. See JavaMail session properties.- See Also:
-
CONNECTION_TIMEOUT
public static final long CONNECTION_TIMEOUTDefault socket connection timeout. See JavaMail session properties.- See Also:
-
SERVER_STARTUP_TIMEOUT
public static final long SERVER_STARTUP_TIMEOUTDefault server startup timeout in milliseconds.- See Also:
-
-
Constructor Details
-
ServerSetup
Creates a configuration.- Parameters:
port- the port for this service. Set to 0 if an available port should be autodetected.bindAddress- the bind address, e.g. 'localhost'protocol- the protocol, seePROTOCOLS
-
-
Method Details
-
getLocalHostAddress
-
getDefaultBindAddress
Gets the public default host address "0.0.0.0".- Returns:
- the public IP host address.
-
isSecure
public boolean isSecure() -
getProtocol
-
getBindAddress
-
getPort
public int getPort() -
getConnectionTimeout
public long getConnectionTimeout() -
setConnectionTimeout
public void setConnectionTimeout(long connectionTimeout) -
getReadTimeout
public long getReadTimeout() -
setReadTimeout
public void setReadTimeout(long readTimeout) -
getWriteTimeout
public long getWriteTimeout() -
setWriteTimeout
public void setWriteTimeout(long writeTimeout) -
getServerStartupTimeout
public long getServerStartupTimeout() -
withPort
Deprecated.useport(int)- will be deprecated in 2.1Creates a deep copy and updates port.- Parameters:
port- the port (0 for dynamic port allocation).- Returns:
- a modified copy.
-
port
Creates a deep copy and updates port.- Parameters:
port- the port (0 for dynamic port allocation).- Returns:
- a modified copy.
-
isDynamicPort
public boolean isDynamicPort()True if available port gets dynamically allocated.- Returns:
- true if enabled.
-
dynamicPort
Enable dynamic port allocation.- Returns:
- a modified copy with dynamic port allocation enabled.
-
isVerbose
public boolean isVerbose() -
setVerbose
- Parameters:
verbose- if true enables JavaMail debug output by setting JavaMail property 'mail.debug'
-
verbose
Creates a deep copy with verbose configured.- Parameters:
verbose- if true enables JavaMail debug output by setting JavaMail property 'mail.debug'- Returns:
- a deep copy with verbose configured
-
setServerStartupTimeout
public void setServerStartupTimeout(long timeoutInMs) Sets the server startup timeout in milliseconds.- Parameters:
timeoutInMs- timeout in milliseconds.
-
configureJavaMailSessionProperties
Creates default properties for a JavaMail session.Concrete server implementations can add protocol-specific settings.
Order of application:
- Default GreenMail properties - e.g. common properties such as
mail.debugwhen log level is debug or protocol specific settings such asmail.smtp.port - ServerSetup configured mail session properties
- Parameter provided properties
mail.PROTOCOL.portFor details see
- https://jakarta.ee/specifications/mail/2.0/apidocs/jakarta.mail/module-summary.html for some general settings
- https://jakarta.ee/specifications/mail/1.6/apidocs/index.html?com/sun/mail/smtp/package-summary.html for valid SMTP properties.
- https://jakarta.ee/specifications/mail/1.6/apidocs/index.html?com/sun/mail/imap/package-summary.html for valid IMAP properties
- https://jakarta.ee/specifications/mail/1.6/apidocs/index.html?com/sun/mail/pop3/package-summary.html for valid POP3 properties.
- Parameters:
properties- additional and optional properties which overwrite automatically added properties. Can be null.debug- sets JavaMail debug properties- Returns:
- default properties.
- Default GreenMail properties - e.g. common properties such as
-
equals
-
hashCode
public int hashCode() -
toString
-
createCopy
Create a deep copy.- Returns:
- a copy of the server setup configuration.
-
createCopy
Create a deep copy.- Parameters:
bindAddress- overwrites bind address when creating deep copy.- Returns:
- a copy of the server setup configuration.
-
createCopy
Create a deep copy.- Parameters:
port- overwrites the port.bindAddress- overwrites bind address.protocol- overwrites the protocol.- Returns:
- a copy of the server setup configuration.
-
mailSessionProperty
Create a new server setup copy, configured with given JavaMail session property.For protocol-specific properties see
- https://jakarta.ee/specifications/mail/2.0/apidocs/jakarta.mail/jakarta/mail/package-summary.html for general settings
- https://jakarta.ee/specifications/mail/1.6/apidocs/index.html?com/sun/mail/smtp/package-summary.html for SMTP properties.
- https://jakarta.ee/specifications/mail/1.6/apidocs/index.html?com/sun/mail/imap/package-summary.html for IMAP properties
- https://jakarta.ee/specifications/mail/1.6/apidocs/index.html?com/sun/mail/pop3/package-summary.html for POP3 properties.
- Parameters:
key- the keyvalue- the value- Returns:
- a deep copy with configured session property
-
createCopy
public static ServerSetup[] createCopy(ServerSetup[] serverSetups, UnaryOperator<ServerSetup> copyMutator) Creates a copy applying given mutator on each copy.- Parameters:
serverSetups- the server setupscopyMutator- the mutator receiving the original server setup and returning a modified copy- Returns:
- mutated copies
-
verbose
Creates a copy with verbose mode enabled.- Parameters:
serverSetups- the server setups.- Returns:
- copies of server setups with verbose mode enabled.
-
dynamicPort
Creates a copy with dynamic ports (auto-detecting available ports) enabled.- Parameters:
serverSetups- the server setups.- Returns:
- copies of server setups with verbose mode enabled.
-
mailSessionProperty
public static ServerSetup[] mailSessionProperty(ServerSetup[] serverSetups, String key, String value) Creates a copy with configured default mail session property.- Parameters:
serverSetups- the server setups.key- the keyvalue- the value- Returns:
- copies of server setups with verbose mode enabled.
- See Also:
-
port(int)- will be deprecated in 2.1