- All Known Implementing Classes:
GoogleMailConfig,MailConfigImpl,MailTrapConfig
public interface MailConfig
This interface represents the configuration for a mail client.
It provides methods to get and set various properties related to the mail configuration.
The properties include SMTP settings, SSL settings, and debug settings.
- Author:
- Besmir Beqiri
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanstatic final booleanstatic final booleanstatic final booleanstatic final Stringstatic final intstatic final booleanstatic final booleanstatic final StartTLSOptionstatic final StringProperty for enabling or disabling debugging.static final StringIftrue, attempt to authenticate the user using the AUTH command.static final StringIftrue, prevents use of the "AUTH DIGEST-MD5" command.static final StringIftrue, prevents use of the "AUTH LOGIN" command.static final StringIf set, lists the authentication mechanisms to consider, and the order in which to consider them.static final StringIftrue, prevents use of theAUTH PLAINcommand.static final StringIftrue, prevents use of the "AUTHENTICATE XOAUTH2" command.static final StringSocket connection timeout value in milliseconds.static final StringThe SMTP server to connect to.static final StringThe SMTP server port to connect to, if the connect() method doesn't explicitly specify one.static final StringIf set totrue, check the server identity as specified by RFC 2595.static final StringIf set totrue, use SSL to connect and use the SSL port by default.static final StringIf set, and a socket factory hasn't been specified, enables use of a MailSSLSocketFactory.static final StringIftrue, enables the use of the "STARTTLS" command (if supported by the server) to switch the connection to a TLS-protected connection before issuing any login commands.static final StringIftrue, requires the use of the "STARTTLS" command.static final StringSocket read timeout value in milliseconds.static final StringDefault user name for SMTP. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull MailConfigcreate()Creates a new instance of MailConfig.Gets the SMTP authentication mechanisms.intGets the SMTP connection timeout.Gets the SMTP host.intGets the SMTP port.Gets the SMTP SSL trust setting.Gets the STARTTLS option.intGets the SMTP timeout.Gets the SMTP user.@NotNull PropertiesGets the mail properties.booleanChecks if mail debugging is enabled.booleanChecks if SMTP authentication is enabled.booleanChecks if the "AUTH DIGEST-MD5" command is disabled.booleanChecks if the "AUTH LOGIN" command is disabled.booleanChecks if the "AUTH PLAIN" command is disabled.booleanChecks if the "AUTH XOAUTH2" command is disabled.booleanChecks if the server identity is checked for SMTP SSL.booleanChecks if SSL is enabled for SMTP.setMailDebug(boolean mailDebug) Sets the mail debugging option.setMailSmtpAuth(boolean mailSmtpAuth) Sets the SMTP authentication option.setMailSmtpAuthDigestMd5Disable(boolean mailSmtpAuthDigestMd5Disable) Sets the option to disable the "AUTH DIGEST-MD5" command.setMailSmtpAuthLoginDisable(boolean mailSmtpAuthLoginDisable) Sets the option to disable the "AUTH LOGIN" command.setMailSmtpAuthMechanisms(String mailSmtpAuthMechanisms) Sets the SMTP authentication mechanisms.setMailSmtpAuthPlainDisable(boolean mailSmtpAuthPlainDisable) Sets the option to disable the "AUTH PLAIN" command.setMailSmtpAuthXOAuth2Disable(boolean mailSmtpAuthXOAuth2Disable) Sets the option to disable the "AUTH XOAUTH2" command.setMailSmtpConnectionTimeout(int mailSmtpConnectionTimeout) Sets the SMTP connection timeout.setMailSmtpHost(String mailSmtpHost) Sets the SMTP host.setMailSmtpPort(int mailSmtpPort) Sets the SMTP port.setMailSmtpSslCheckServerIdentity(boolean mailSmtpSslCheckServerIdentity) Sets the option to check the server identity for SMTP SSL.setMailSmtpSslEnable(boolean mailSmtpSslEnable) Sets the option to enable SSL for SMTP.setMailSmtpSslTrust(String mailSmtpSslTrust) Sets the SMTP SSL trust setting.setMailSmtpStartTLS(StartTLSOption mailSmtpStarttls) Sets the STARTTLS option.setMailSmtpTimeout(int mailSmtpTimeout) Sets the SMTP timeout.setMailSmtpUser(String mailSmtpUser) Sets the SMTP user.
-
Field Details
-
MAIL_DEBUG
Property for enabling or disabling debugging.- See Also:
-
MAIL_SMTP_USER
Default user name for SMTP.- See Also:
-
MAIL_SMTP_HOST
The SMTP server to connect to.- See Also:
-
MAIL_SMTP_PORT
The SMTP server port to connect to, if the connect() method doesn't explicitly specify one. Defaults to25.- See Also:
-
MAIL_SMTP_CONNECTIONTIMEOUT
Socket connection timeout value in milliseconds. This timeout is implemented by java.net.Socket. Default is infinite timeout.- See Also:
-
MAIL_SMTP_TIMEOUT
Socket read timeout value in milliseconds. This timeout is implemented by java.net.Socket. Default is infinite timeout.- See Also:
-
MAIL_SMTP_AUTH
Iftrue, attempt to authenticate the user using the AUTH command. Defaults tofalse.- See Also:
-
MAIL_SMTP_AUTH_MECHANISMS
If set, lists the authentication mechanisms to consider, and the order in which to consider them. Only mechanisms supported by the server and supported by the current implementation will be used. The default is "LOGIN PLAIN DIGEST-MD5 NTLM", which includes all the authentication mechanisms supported by the current implementation except "XOAUTH2".- See Also:
-
MAIL_SMTP_AUTH_LOGIN_DISABLE
Iftrue, prevents use of the "AUTH LOGIN" command. Default isfalse.- See Also:
-
MAIL_SMTP_AUTH_PLAIN_DISABLE
Iftrue, prevents use of theAUTH PLAINcommand. Default isfalse.- See Also:
-
MAIL_SMTP_AUTH_DIGEST_MD5_DISABLE
Iftrue, prevents use of the "AUTH DIGEST-MD5" command. Default isfalse.- See Also:
-
MAIL_SMTP_AUTH_XOAUTH2_DISABLE
Iftrue, prevents use of the "AUTHENTICATE XOAUTH2" command. Because the OAuth 2.0 protocol requires a special access token instead of a password, this mechanism is disabled by default. Enable it by explicitly setting this property to "false" or by setting the "mail.smtp.auth.mechanisms" property to "XOAUTH2".- See Also:
-
MAIL_SMTP_STARTTLS_ENABLE
Iftrue, enables the use of the "STARTTLS" command (if supported by the server) to switch the connection to a TLS-protected connection before issuing any login commands. If the server does not support "STARTTLS", the connection continues without the use of TLS; see the "mail.smtp.starttls.required" property to fail if "STARTTLS" isn't supported. Note that an appropriate trust store must be configured so that the client will trust the server's certificate. Defaults tofalse.- See Also:
-
MAIL_SMTP_STARTTLS_REQUIRED
Iftrue, requires the use of the "STARTTLS" command. If the server doesn't support the "STARTTLS" command, or the command fails, the connect method will fail. Defaults tofalse.- See Also:
-
MAIL_SMTP_SSL_ENABLE
If set totrue, use SSL to connect and use the SSL port by default. Defaults tofalsefor the "smtp" protocol andtruefor the "smtps" protocol.- See Also:
-
MAIL_SMTP_SSL_CHECKSERVERIDENTITY
If set totrue, check the server identity as specified by RFC 2595. These additional checks based on the content of the server's certificate are intended to prevent man-in-the-middle attacks. Defaults tofalse.- See Also:
-
MAIL_SMTP_SSL_TRUST
If set, and a socket factory hasn't been specified, enables use of a MailSSLSocketFactory. If set to "*", all hosts are trusted. If set to a whitespace separated list of hosts, those hosts are trusted. Otherwise, trust depends on the certificate the server presents.- See Also:
-
DEFAULT_MAIL_DEBUG
static final boolean DEFAULT_MAIL_DEBUG- See Also:
-
DEFAULT_MAIL_SMTP_HOST
- See Also:
-
DEFAULT_MAIL_SMTP_PORT
static final int DEFAULT_MAIL_SMTP_PORT- See Also:
-
DEFAULT_MAIL_SMTP_AUTH
static final boolean DEFAULT_MAIL_SMTP_AUTH- See Also:
-
DEFAULT_MAIL_SMTP_AUTH_DIGEST_MD5_DISABLE
static final boolean DEFAULT_MAIL_SMTP_AUTH_DIGEST_MD5_DISABLE- See Also:
-
DEFAULT_MAIL_SMTP_AUTH_XOAUTH2_DISABLE
static final boolean DEFAULT_MAIL_SMTP_AUTH_XOAUTH2_DISABLE- See Also:
-
DEFAULT_MAIL_SMTP_STARTTLS
-
DEFAULT_MAIL_SMTP_SSL_ENABLE
static final boolean DEFAULT_MAIL_SMTP_SSL_ENABLE- See Also:
-
DEFAULT_MAIL_SMTP_SSL_CHECKSERVERIDENTITY
static final boolean DEFAULT_MAIL_SMTP_SSL_CHECKSERVERIDENTITY- See Also:
-
-
Method Details
-
create
Creates a new instance of MailConfig.- Returns:
- a new
MailConfiginstance.
-
getProperties
Gets the mail properties.- Returns:
- a
Propertiesobject containing mail properties
-
isMailDebug
boolean isMailDebug()Checks if mail debugging is enabled.- Returns:
trueif mail debugging is enabled,falseotherwise
-
setMailDebug
Sets the mail debugging option.- Parameters:
mailDebug-trueto enable mail debugging,falseto disable it- Returns:
- the updated
MailConfiginstance for method chaining
-
getMailSmtpUser
String getMailSmtpUser()Gets the SMTP user.- Returns:
- the SMTP user as a string
-
setMailSmtpUser
Sets the SMTP user.- Parameters:
mailSmtpUser- the SMTP user to set- Returns:
- the updated
MailConfiginstance for method chaining
-
getMailSmtpHost
String getMailSmtpHost()Gets the SMTP host.- Returns:
- the SMTP host
-
setMailSmtpHost
Sets the SMTP host.- Parameters:
mailSmtpHost- the SMTP host to set- Returns:
- the updated
MailConfiginstance for method chaining
-
getMailSmtpPort
int getMailSmtpPort()Gets the SMTP port.- Returns:
- the SMTP port
-
setMailSmtpPort
Sets the SMTP port.- Parameters:
mailSmtpPort- the SMTP port to set- Returns:
- the updated
MailConfiginstance for method chaining
-
getMailSmtpConnectionTimeout
int getMailSmtpConnectionTimeout()Gets the SMTP connection timeout.- Returns:
- the SMTP connection timeout in milliseconds
-
setMailSmtpConnectionTimeout
Sets the SMTP connection timeout.- Parameters:
mailSmtpConnectionTimeout- the SMTP connection timeout in milliseconds- Returns:
- the updated
MailConfiginstance for method chaining
-
getMailSmtpTimeout
int getMailSmtpTimeout()Gets the SMTP timeout.- Returns:
- the SMTP timeout in milliseconds
-
setMailSmtpTimeout
Sets the SMTP timeout.- Parameters:
mailSmtpTimeout- the SMTP timeout in milliseconds- Returns:
- the updated
MailConfiginstance for method chaining
-
isMailSmtpAuth
boolean isMailSmtpAuth()Checks if SMTP authentication is enabled.- Returns:
trueif SMTP authentication is enabled,falseotherwise
-
setMailSmtpAuth
Sets the SMTP authentication option.- Parameters:
mailSmtpAuth-trueto enable SMTP authentication,falseto disable- Returns:
- the updated
MailConfiginstance for method chaining
-
getMailSmtpAuthMechanisms
String getMailSmtpAuthMechanisms()Gets the SMTP authentication mechanisms.- Returns:
- a string representing the SMTP authentication mechanisms
-
setMailSmtpAuthMechanisms
Sets the SMTP authentication mechanisms.- Parameters:
mailSmtpAuthMechanisms- the SMTP authentication mechanisms to set- Returns:
- the updated
MailConfiginstance for method chaining
-
isMailSmtpAuthLoginDisable
boolean isMailSmtpAuthLoginDisable()Checks if the "AUTH LOGIN" command is disabled.- Returns:
trueif the "AUTH LOGIN" command is disabled,falseotherwise
-
setMailSmtpAuthLoginDisable
Sets the option to disable the "AUTH LOGIN" command.- Parameters:
mailSmtpAuthLoginDisable-trueto disable the "AUTH LOGIN" command,falseto enable- Returns:
- the updated
MailConfiginstance for method chaining
-
isMailSmtpAuthPlainDisable
boolean isMailSmtpAuthPlainDisable()Checks if the "AUTH PLAIN" command is disabled.- Returns:
trueif the "AUTH PLAIN" command is disabled,falseotherwise
-
setMailSmtpAuthPlainDisable
Sets the option to disable the "AUTH PLAIN" command.- Parameters:
mailSmtpAuthPlainDisable-trueto disable the "AUTH PLAIN" command,falseto enable- Returns:
- the updated
MailConfiginstance for method chaining
-
isMailSmtpAuthDigestMd5Disable
boolean isMailSmtpAuthDigestMd5Disable()Checks if the "AUTH DIGEST-MD5" command is disabled.- Returns:
trueif the "AUTH DIGEST-MD5" command is disabled,falseotherwise
-
setMailSmtpAuthDigestMd5Disable
Sets the option to disable the "AUTH DIGEST-MD5" command.- Parameters:
mailSmtpAuthDigestMd5Disable-trueto disable the "AUTH DIGEST-MD5" command,falseto enable- Returns:
- the updated
MailConfiginstance for method chaining
-
isMailSmtpAuthXOAuth2Disable
boolean isMailSmtpAuthXOAuth2Disable()Checks if the "AUTH XOAUTH2" command is disabled.- Returns:
trueif the "AUTH XOAUTH2" command is disabled,falseotherwise
-
setMailSmtpAuthXOAuth2Disable
Sets the option to disable the "AUTH XOAUTH2" command.- Parameters:
mailSmtpAuthXOAuth2Disable-trueto disable the "AUTH XOAUTH2" command,falseto enable- Returns:
- the updated
MailConfiginstance for method chaining
-
getMailSmtpStartTLS
StartTLSOption getMailSmtpStartTLS()Gets the STARTTLS option.- Returns:
- the STARTTLS option
-
setMailSmtpStartTLS
Sets the STARTTLS option.- Parameters:
mailSmtpStarttls- the STARTTLS option to set- Returns:
- the updated
MailConfiginstance for method chaining
-
isMailSmtpSslEnable
boolean isMailSmtpSslEnable()Checks if SSL is enabled for SMTP.- Returns:
trueif SSL is enabled,falseotherwise
-
setMailSmtpSslEnable
Sets the option to enable SSL for SMTP.- Parameters:
mailSmtpSslEnable-trueto enable SSL,falseto disable- Returns:
- the updated
MailConfiginstance for method chaining
-
isMailSmtpSslCheckServerIdentity
boolean isMailSmtpSslCheckServerIdentity()Checks if the server identity is checked for SMTP SSL.- Returns:
trueif the server identity is checked,falseotherwise
-
setMailSmtpSslCheckServerIdentity
Sets the option to check the server identity for SMTP SSL.- Parameters:
mailSmtpSslCheckServerIdentity-trueto check the server identity,falseto disable- Returns:
- the updated
MailConfiginstance for method chaining
-
getMailSmtpSslTrust
String getMailSmtpSslTrust()Gets the SMTP SSL trust setting.- Returns:
- a string representing the SMTP SSL trust setting
-
setMailSmtpSslTrust
Sets the SMTP SSL trust setting.- Parameters:
mailSmtpSslTrust- the SMTP SSL trust setting to set- Returns:
- the updated
MailConfiginstance for method chaining
-