public class MailConfig extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_USER_AGENT |
| Constructor and Description |
|---|
MailConfig()
construct a config object with default options
|
MailConfig(JsonObject config)
construct config object from Json representation
|
MailConfig(MailConfig other)
copy config object from another MailConfig object
|
MailConfig(String hostname)
construct a config object with hostname and default options
|
MailConfig(String hostname,
int port)
construct a config object with hostname/port and default options
|
MailConfig(String hostname,
int port,
StartTLSOptions starttls,
LoginOption login)
construct a config object with hostname/port and security and login options
|
| Modifier and Type | Method and Description |
|---|---|
MailConfig |
addDKIMSignOption(DKIMSignOptions dkimSignOptions)
Adds a DKIMSignOptions.
|
boolean |
equals(Object o) |
String |
getAuthMethods()
get string of allowed auth methods, if set only these methods will be used
if the server supports them.
|
DKIMSignOptions |
getDKIMSignOption()
Gets the DKIM options.
|
List<DKIMSignOptions> |
getDKIMSignOptions()
Gets the DKIM options.
|
Set<String> |
getEnabledSecureTransportProtocols()
Returns the enabled SSL/TLS protocols
|
String |
getHostname()
get the hostname of the mailserver
|
String |
getKeyStore()
get the key store filename to be used when opening SMTP connections
|
String |
getKeyStorePassword()
get the key store password to be used when opening SMTP connections
|
LoginOption |
getLogin()
get login options
|
int |
getMaxPoolSize()
get the max allowed number of open connections to the mailserver
if not set the default is 10
|
String |
getOwnHostname()
get the hostname to be used for HELO/EHLO and the Message-ID
|
String |
getPassword()
get password
|
int |
getPort()
get the port of the mailserver
|
StartTLSOptions |
getStarttls()
get security (TLS) options
|
String |
getUserAgent()
Gets the Mail User Agent(MUA) name that will be used to generate boundary and message id.
|
String |
getUsername()
get username
|
int |
hashCode() |
boolean |
isAllowRcptErrors()
get if sending allows rcpt errors (default is false)
|
boolean |
isDisableEsmtp()
get if ESMTP should be tried as first command (EHLO) (default is true)
|
boolean |
isEnableDKIM()
Is DKIM enabled, defaults to false.
|
boolean |
isKeepAlive()
get if connection pool is enabled
default is true
|
boolean |
isSsl()
get whether ssl is used on connect
|
boolean |
isTrustAll()
get whether to trust all certificates on ssl connect
|
MailConfig |
setAllowRcptErrors(boolean allowRcptErrors)
set if sending allows rcpt errors
|
MailConfig |
setAuthMethods(String authMethods)
set string of allowed auth methods.
|
MailConfig |
setDisableEsmtp(boolean disableEsmtp)
set if ESMTP should be tried as first command (EHLO)
|
MailConfig |
setDKIMSignOption(DKIMSignOptions dkimSignOptions)
Sets one DKIMSignOptions for convenient.
|
MailConfig |
setDKIMSignOptions(List<DKIMSignOptions> dkimSignOptions)
Sets DKIMSignOptions.
|
MailConfig |
setEnableDKIM(boolean enableDKIM)
Sets true to enable DKIM Signatures, sets false to disable it.
|
MailConfig |
setEnabledSecureTransportProtocols(Set<String> enabledSecureTransportProtocols)
Sets the list of enabled SSL/TLS protocols.
|
MailConfig |
setHostname(String hostname)
Set the hostname of the smtp server.
|
MailConfig |
setKeepAlive(boolean keepAlive)
set if connection pool is enabled
default is true
|
MailConfig |
setKeyStore(String keyStore)
get the key store filename to be used when opening SMTP connections
|
MailConfig |
setKeyStorePassword(String keyStorePassword)
get the key store password to be used when opening SMTP connections
|
MailConfig |
setLogin(LoginOption login)
Set the login mode for the connection.
|
MailConfig |
setMaxPoolSize(int maxPoolSize)
set the max allowed number of open connections to the mail server
if not set the default is 10
|
MailConfig |
setOwnHostname(String ownHostname)
set the hostname to be used for HELO/EHLO and the Message-ID
|
MailConfig |
setPassword(String password)
Set the password for the login.
|
MailConfig |
setPort(int port)
Set the port of the smtp server.
|
MailConfig |
setSsl(boolean ssl)
Set the sslOnConnect mode for the connection.
|
MailConfig |
setStarttls(StartTLSOptions starttls)
Set the tls security mode for the connection.
|
MailConfig |
setTrustAll(boolean trustAll)
set whether to trust all certificates on ssl connect the option is also
applied to STARTTLS operation
|
MailConfig |
setUserAgent(String userAgent)
Sets the Mail User Agent(MUA) name.
|
MailConfig |
setUsername(String username)
Set the username for the login.
|
JsonObject |
toJson()
convert config object to Json representation
|
public static final String DEFAULT_USER_AGENT
public MailConfig()
public MailConfig(String hostname)
hostname - the hostname of the mail serverpublic MailConfig(String hostname, int port)
hostname - the hostname of the mail serverport - the port of the mail serverpublic MailConfig(String hostname, int port, StartTLSOptions starttls, LoginOption login)
hostname - the hostname of the mail serverport - the port of the mail serverstarttls - whether to use TLS or notlogin - whether to use Login or notpublic MailConfig(MailConfig other)
other - the object to be copiedpublic MailConfig(JsonObject config)
config - the config to copypublic String getHostname()
public MailConfig setHostname(String hostname)
hostname - the hostname (default is localhost)public int getPort()
public MailConfig setPort(int port)
port - the port (default is 25)public StartTLSOptions getStarttls()
public MailConfig setStarttls(StartTLSOptions starttls)
Either NONE, OPTIONAL or REQUIRED
starttls - (default is OPTIONAL)public LoginOption getLogin()
public MailConfig setLogin(LoginOption login)
Either DISABLED, OPTIONAL or REQUIRED
login - (default is OPTIONAL)public String getUsername()
public MailConfig setUsername(String username)
username - the usernamepublic String getPassword()
public MailConfig setPassword(String password)
password - the passwordpublic boolean isSsl()
public MailConfig setSsl(boolean ssl)
ssl - true is ssl is usedpublic Set<String> getEnabledSecureTransportProtocols()
public MailConfig setEnabledSecureTransportProtocols(Set<String> enabledSecureTransportProtocols)
enabledSecureTransportProtocols - the SSL/TLS protocols to enablepublic boolean isTrustAll()
public MailConfig setTrustAll(boolean trustAll)
trustAll - trust all certificatespublic String getKeyStore()
public MailConfig setKeyStore(String keyStore)
if not set, an options object will be created based on other settings (ssl and trustAll)
keyStore - the key store filename to be setpublic String getKeyStorePassword()
public MailConfig setKeyStorePassword(String keyStorePassword)
keyStorePassword - the key store passwords to be setpublic String getAuthMethods()
public MailConfig setAuthMethods(String authMethods)
authMethods - the authMethods to setpublic String getOwnHostname()
public MailConfig setOwnHostname(String ownHostname)
ownHostname - my own hostname to setpublic int getMaxPoolSize()
public MailConfig setMaxPoolSize(int maxPoolSize)
public boolean isKeepAlive()
if the connection pooling is disabled, the max number of sockets is enforced nevertheless
public MailConfig setKeepAlive(boolean keepAlive)
if the connection pooling is disabled, the max number of sockets is enforced nevertheless
public boolean isAllowRcptErrors()
if true, the mail will be sent to the recipients that the server accepted, if any
public MailConfig setAllowRcptErrors(boolean allowRcptErrors)
if true, the mail will be sent to the recipients that the server accepted, if any
allowRcptErrors - the allowRcptErrors to set (default is false)public boolean isDisableEsmtp()
rfc 1869 states that clients should always attempt EHLO as first command to determine if ESMTP is supported, if this returns an error code, HELO is tried to use old SMTP. If there is a server that does not support EHLO and does not give an error code back, the connection should be closed and retried with HELO. We do not do that and rather support turning off ESMTP with a setting. The odds of this actually happening are very small since the client will not connect to arbitrary smtp hosts on the internet. Since the client knows that is connects to a host that doesn't support ESMTP/EHLO in that way, the property has to be set to false.
public MailConfig setDisableEsmtp(boolean disableEsmtp)
rfc 1869 states that clients should always attempt EHLO as first command to determine if ESMTP is supported, if this returns an error code, HELO is tried to use old SMTP. If there is a server that does not support EHLO and does not give an error code back, the connection should be closed and retried with HELO. We do not do that and rather support turning off ESMTP with a setting. The odds of this actually happening are very small since the client will not connect to arbitrary smtp hosts on the internet. Since the client knows that is connects to a host that doesn't support ESMTP/EHLO in that way, the property has to be set to false.
disableEsmtp - the disableEsmtp to set (default is true)public String getUserAgent()
public MailConfig setUserAgent(String userAgent)
It is used to generate the boundary in case of MultiPart email and the Message-ID.
If null is set, DEFAULT_USER_AGENT is used.
userAgent - the Mail User Agent(MUA) name used to generate boundary and message id
length of userAgent must be smaller than 40 so that the generated boundary
has no longer 70 characters.public boolean isEnableDKIM()
public MailConfig setEnableDKIM(boolean enableDKIM)
This is used most for temporary disable DKIM without removing DKIM opations from current config.
enableDKIM - if DKIM Singature should be enabledpublic List<DKIMSignOptions> getDKIMSignOptions()
public MailConfig addDKIMSignOption(DKIMSignOptions dkimSignOptions)
dkimSignOptions - the DKIMSignOptionspublic MailConfig setDKIMSignOptions(List<DKIMSignOptions> dkimSignOptions)
dkimSignOptions - the DKIM optionspublic MailConfig setDKIMSignOption(DKIMSignOptions dkimSignOptions)
dkimSignOptions - the DKIM optionspublic DKIMSignOptions getDKIMSignOption()
public JsonObject toJson()
Copyright © 2019 Eclipse. All rights reserved.