public abstract class MailerGenericBuilder<T extends MailerGenericBuilder> extends Object
To start a new Mailer builder, refer to MailerBuilder
.
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_POOL_SIZE
For multi-threaded scenario's where a batch of emails sent asynchronously, the default maximum number of threads is 10.
|
static int |
DEFAULT_PROXY_BRIDGE_PORT
The temporary intermediary SOCKS5 relay server bridge is a server that sits in between JavaMail and the remote proxy.
|
static int |
DEFAULT_SESSION_TIMEOUT_MILLIS
The default maximum timeout value for the transport socket is 60000 milliseconds (affects socket connect-,
read- and write timeouts).
|
static boolean |
DEFAULT_TRANSPORT_MODE_LOGGING_ONLY
Defaults to false, sending mails rather than just only logging the mails.
|
Modifier and Type | Method and Description |
---|---|
T |
clearEmailAddressCriteria()
Removes all email address criteria, meaning validation won't take place.
|
T |
clearProperties()
Removes all properties.
|
T |
clearProxy()
Empties all proxy configuration.
|
T |
clearTrustedSSLHosts()
Removes all trusted hosts from the list.
|
Boolean |
getDebugLogging() |
EnumSet<org.hazlewood.connor.bottema.emailaddress.EmailAddressCriteria> |
getEmailAddressCriteria() |
Properties |
getProperties() |
Integer |
getProxyBridgePort() |
String |
getProxyHost() |
String |
getProxyPassword() |
Integer |
getProxyPort() |
String |
getProxyUsername() |
Integer |
getSessionTimeout() |
List<String> |
getSslHostsToTrust() |
Integer |
getThreadPoolSize() |
boolean |
getTransportModeLoggingOnly() |
Boolean |
getTrustAllSSLHost() |
T |
resetEmailAddressCriteria()
Resets emailAddressCriteria to
EmailAddressCriteria.RFC_COMPLIANT . |
T |
resetSessionTimeout()
Resets session time to its default (60000).
|
T |
resetThreadpoolSize()
Resets threadPoolSize to its default (10).
|
T |
resetTransportModeLoggingOnly()
Resets transportModeLoggingOnly to false.
|
T |
trustingAllHosts(Boolean trustAllHosts)
Configures the current session to trust all hosts and don't validate any SSL keys.
|
T |
trustingSSLHosts(String... sslHostsToTrust)
Configures the new session to only accept server certificates issued to one of the provided hostnames, and disables certificate issuer
validation.
|
T |
withDebugLogging(Boolean debugLogging)
This flag is set on the Session instance through
Session.setDebug(boolean) so that it generates debug information. |
T |
withEmailAddressCriteria(EnumSet<org.hazlewood.connor.bottema.emailaddress.EmailAddressCriteria> emailAddressCriteria)
Sets the email address validation restrictions when validating and sending emails using the current
Mailer instance. |
T |
withProperties(Map<String,String> properties) |
T |
withProperties(Properties properties)
Adds the given properties to the total list applied to the
Session when building a mailer. |
T |
withProperty(String propertyName,
String propertyValue) |
T |
withProxy(String proxyHost,
Integer proxyPort)
Delegates to
withProxyHost(String) and withProxyPort(Integer) . |
T |
withProxy(String proxyHost,
Integer proxyPort,
String proxyUsername,
String proxyPassword)
|
T |
withProxyBridgePort(Integer proxyBridgePort)
Relevant only when using username authentication with a proxy.
|
T |
withProxyHost(String proxyHost)
Sets the optional proxy host, which will override any default that might have been set (through properties file or programmatically).
|
T |
withProxyPassword(String proxyPassword)
Sets the optional password to authenticate with the proxy.
|
T |
withProxyPort(Integer proxyPort)
Sets the proxy port, which will override any default that might have been set (through properties file or programmatically).
|
T |
withProxyUsername(String proxyUsername)
Sets the optional username to authenticate with the proxy.
|
T |
withSessionTimeout(Integer sessionTimeout)
Controls the timeout to use when sending emails (affects socket connect-, read- and write timeouts).
|
T |
withThreadPoolSize(Integer defaultPoolSize)
Controls the maximum number of threads when sending emails in async fashion.
|
T |
withTransportModeLoggingOnly(Boolean transportModeLoggingOnly)
Determines whether at the very last moment an email is sent out using JavaMail's native API or whether the email is simply only logged.
|
public static final int DEFAULT_SESSION_TIMEOUT_MILLIS
public static final int DEFAULT_POOL_SIZE
public static final int DEFAULT_PROXY_BRIDGE_PORT
public static final boolean DEFAULT_TRANSPORT_MODE_LOGGING_ONLY
public T withProxy(@Nullable String proxyHost, @Nullable Integer proxyPort)
withProxyHost(String)
and withProxyPort(Integer)
.public T withProxy(@Nullable String proxyHost, @Nullable Integer proxyPort, @Nullable String proxyUsername, @Nullable String proxyPassword)
public T withProxyHost(@Nullable String proxyHost)
public T withProxyPort(@Nullable Integer proxyPort)
Proxy port is required if a proxyHost has been configured.
public T withProxyUsername(@Nullable String proxyUsername)
If set, Simple Java Mail will use its built in proxy bridge to perform the SOCKS authentication, as the underlying JavaMail framework doesn't support this directly.
The path will be:
Simple Java Mail -> JavaMail -> anonymous authentication with local proxy bridge -> full authentication with remote SOCKS
proxy
.
public T withProxyPassword(@Nullable String proxyPassword)
withProxyUsername(String)
public T withProxyBridgePort(@Nullable Integer proxyBridgePort)
Overrides the default for the intermediary SOCKS5 relay server bridge, which is a server that sits in between JavaMail and the remote proxy. Defaults to 1081 if no custom default property was configured.
withProxyUsername(String)
public T withDebugLogging(@Nullable Boolean debugLogging)
Session.setDebug(boolean)
so that it generates debug information. To get more
information out of the underlying JavaMail framework or out of Simple Java Mail, increase logging config of your chosen logging framework.public T withSessionTimeout(@Nullable Integer sessionTimeout)
public T withEmailAddressCriteria(@Nonnull EnumSet<org.hazlewood.connor.bottema.emailaddress.EmailAddressCriteria> emailAddressCriteria)
Mailer
instance.
Defaults to EmailAddressCriteria.RFC_COMPLIANT
if not overridden with a (null
) value.
EmailAddressCriteria
,
clearEmailAddressCriteria()
,
resetEmailAddressCriteria()
public T withThreadPoolSize(@Nonnull Integer defaultPoolSize)
DEFAULT_POOL_SIZE
.resetThreadpoolSize()
public T withTransportModeLoggingOnly(@Nonnull Boolean transportModeLoggingOnly)
resetTransportModeLoggingOnly()
public T trustingSSLHosts(String... sslHostsToTrust)
Passing an empty list resets the current session's trust behavior to the default, and is equivalent to never calling this method in the first place.
Security warning: Any certificate matching any of the provided host names will be accepted, regardless of the certificate issuer; attackers can abuse this behavior by serving a matching self-signed certificate during a man-in-the-middle attack.
This method sets the property mail.smtp.ssl.trust
to a space-separated list of the provided hosts
. If the provided list is
empty, mail.smtp.ssl.trust
is unset.
mail.smtp.ssl.trust
,
trustingAllHosts(Boolean)
public T trustingAllHosts(@Nonnull Boolean trustAllHosts)
Refer to https://javamail.java.net/nonav/docs/api/com/sun/mail/smtp/package-summary.html#mail.smtp.ssl.trust
trustingSSLHosts(String...)
public T withProperties(@Nonnull Properties properties)
Session
when building a mailer.public T withProperties(@Nonnull Map<String,String> properties)
withProperties(Properties)
,
clearProperties()
public T withProperty(@Nonnull String propertyName, @Nullable String propertyValue)
withProperties(Properties)
,
clearProperties()
public T resetSessionTimeout()
withSessionTimeout(Integer)
public T resetEmailAddressCriteria()
EmailAddressCriteria.RFC_COMPLIANT
.public T resetThreadpoolSize()
withThreadPoolSize(Integer)
public T resetTransportModeLoggingOnly()
withTransportModeLoggingOnly(Boolean)
public T clearProxy()
public T clearEmailAddressCriteria()
public T clearTrustedSSLHosts()
trustingSSLHosts(String...)
public T clearProperties()
withProperties(Properties)
public String getProxyHost()
withProxyHost(String)
public Integer getProxyPort()
withProxyPort(Integer)
public String getProxyUsername()
withProxyUsername(String)
public String getProxyPassword()
withProxyPassword(String)
public Integer getProxyBridgePort()
withProxyBridgePort(Integer)
public Boolean getDebugLogging()
withDebugLogging(Boolean)
public Integer getSessionTimeout()
withSessionTimeout(Integer)
public EnumSet<org.hazlewood.connor.bottema.emailaddress.EmailAddressCriteria> getEmailAddressCriteria()
withEmailAddressCriteria(EnumSet)
public Integer getThreadPoolSize()
withThreadPoolSize(Integer)
public List<String> getSslHostsToTrust()
trustingSSLHosts(String...)
public Boolean getTrustAllSSLHost()
trustingAllHosts(Boolean)
public boolean getTransportModeLoggingOnly()
withTransportModeLoggingOnly(Boolean)
public Properties getProperties()
withProperties(Properties)
Copyright © 2019. All rights reserved.