public static final class SMTPServer.Builder extends Object
| Constructor and Description |
|---|
Builder() |
public SMTPServer.Builder bindAddress(InetAddress bindAddress)
public SMTPServer.Builder bindAddress(Optional<InetAddress> bindAddress)
public SMTPServer.Builder hostName(String hostName)
public SMTPServer.Builder port(int port)
public SMTPServer.Builder backlog(int backlogSize)
backlogSize - The backlog argument must be a >= 0. If the value passed is 0,
then the default value (50) will be assumed.public SMTPServer.Builder softwareName(String name)
public SMTPServer.Builder messageHandler(BasicMessageListener listener)
public SMTPServer.Builder messageHandlerFactory(MessageHandlerFactory factory)
public SMTPServer.Builder simpleMessageListener(SimpleMessageListener listener)
public SMTPServer.Builder authenticationHandlerFactory(AuthenticationHandlerFactory factory)
factory - the AuthenticationHandlerFactory which performs
authentication in the SMTP AUTH command. If empty, 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.public SMTPServer.Builder executorService(ExecutorService executor)
executor - the ExecutorService that will handle client connections, one task
per connection. The SMTPServer will shut down this ExecutorService
when the SMTPServer itself stops. If not specified, a default one
is created by Executors.newCachedThreadPool().public SMTPServer.Builder enableTLS(boolean value)
public SMTPServer.Builder fromAddressValidator(Predicate<String> fromAddressValidator)
fromAddressValidator - the validator that will be applied to the address in MAIL
FROM commandpublic SMTPServer.Builder 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 SMTPServer.Builder hideTLS(boolean value)
public SMTPServer.Builder hideTLS()
public SMTPServer.Builder requireTLS(boolean value)
value - true to require a TLS handshake, false to allow operation with or
without TLS. Default is false; ignored when disableTLS=true.public SMTPServer.Builder requireTLS()
public SMTPServer.Builder requireAuth(boolean value)
value - true for mandatory smtp authentication, i.e. no mail mail be
accepted until authentication succeeds. Don't forget to set
authenticationHandlerFactory to allow client
authentication. Defaults to false.public SMTPServer.Builder requireAuth()
public SMTPServer.Builder showAuthCapabilitiesBeforeSTARTTLS(boolean value)
false.
Normally you would not want to advertise AUTH related capabilities before a STARTTLS is sent so that credentials do not go in the clear. However, the use of implicit STARTTLS (the property `mail.smtp.starttls.enable` is not set) by a jakarta.mail client (e.g. 1.6.4) prevents AUTH happening. See issue #21. To resolve this issue with jakarta.mail and implicit STARTTLS we provide explicit control over if AUTH capabilities are shown before STARTTLS.
value - boolean value, default is falsepublic SMTPServer.Builder insertReceivedHeaders(boolean value)
public SMTPServer.Builder insertReceivedHeaders()
public SMTPServer.Builder maxConnections(int maxConnections)
public SMTPServer.Builder connectionTimeoutMs(int connectionTimeoutMs)
public SMTPServer.Builder connectionTimeout(int connectionTimeout, TimeUnit unit)
public SMTPServer.Builder maxRecipients(int maxRecipients)
maxRecipients - The maximum number of recipients that this server accepts per
message delivery request.public SMTPServer.Builder maxMessageSize(int maxMessageSize)
maxMessageSize - The maximum size of a message that the server will accept. This
value is advertised during the EHLO phase if it is larger than 0.
If the message size specified by the client during the MAIL phase,
the message will be rejected at that time. (RFC 1870) Default is
0. Note this doesn't actually enforce any limits on the message
being read; you must do that yourself when reading data.public SMTPServer.Builder sessionIdFactory(SessionIdFactory factory)
SessionIdFactory which will allocate a unique identifier for
each mail sessions. If not set, a reasonable default will be used.public SMTPServer.Builder sessionHandler(SessionHandler sessionHandler)
SessionHandler which will track allocated session and connections.public SMTPServer.Builder proxyHandler(ProxyHandler proxyHandler)
ProxyHandler which will handle proxy packets before SMTP protocol.public SMTPServer.Builder serverSocketFactory(ServerSocketCreator serverSocketCreator)
public SMTPServer.Builder serverSocketFactory(SSLServerSocketFactory factory)
public SMTPServer.Builder serverSocketFactory(SSLContext context)
public SMTPServer.Builder startTlsSocketFactory(SSLSocketCreator creator)
public SMTPServer.Builder startTlsSocketFactory(SSLContext context)
public SMTPServer.Builder startTlsSocketFactory(SSLContext context, boolean requireClientCertificate)
public SMTPServer.Builder serverThreadName(String name)
org.subethamail.smtp.server.ServerThread {bindAddress}:{port}name - - thread namepublic SMTPServer.Builder serverThreadNameProvider(Function<SMTPServer,String> provider)
public SMTPServer build()
Copyright © 2006–2024. All rights reserved.