Interface MailConfig

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 Details

    • MAIL_DEBUG

      static final String MAIL_DEBUG
      Property for enabling or disabling debugging.
      See Also:
    • MAIL_SMTP_USER

      static final String MAIL_SMTP_USER
      Default user name for SMTP.
      See Also:
    • MAIL_SMTP_HOST

      static final String MAIL_SMTP_HOST
      The SMTP server to connect to.
      See Also:
    • MAIL_SMTP_PORT

      static final String MAIL_SMTP_PORT
      The SMTP server port to connect to, if the connect() method doesn't explicitly specify one. Defaults to 25.
      See Also:
    • MAIL_SMTP_CONNECTIONTIMEOUT

      static final String 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

      static final String 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

      static final String MAIL_SMTP_AUTH
      If true, attempt to authenticate the user using the AUTH command. Defaults to false.
      See Also:
    • MAIL_SMTP_AUTH_MECHANISMS

      static final String 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

      static final String MAIL_SMTP_AUTH_LOGIN_DISABLE
      If true, prevents use of the "AUTH LOGIN" command. Default is false.
      See Also:
    • MAIL_SMTP_AUTH_PLAIN_DISABLE

      static final String MAIL_SMTP_AUTH_PLAIN_DISABLE
      If true, prevents use of the AUTH PLAIN command. Default is false.
      See Also:
    • MAIL_SMTP_AUTH_DIGEST_MD5_DISABLE

      static final String MAIL_SMTP_AUTH_DIGEST_MD5_DISABLE
      If true, prevents use of the "AUTH DIGEST-MD5" command. Default is false.
      See Also:
    • MAIL_SMTP_AUTH_XOAUTH2_DISABLE

      static final String MAIL_SMTP_AUTH_XOAUTH2_DISABLE
      If true, 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

      static final String MAIL_SMTP_STARTTLS_ENABLE
      If true, 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 to false.
      See Also:
    • MAIL_SMTP_STARTTLS_REQUIRED

      static final String MAIL_SMTP_STARTTLS_REQUIRED
      If true, 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 to false.
      See Also:
    • MAIL_SMTP_SSL_ENABLE

      static final String MAIL_SMTP_SSL_ENABLE
      If set to true, use SSL to connect and use the SSL port by default. Defaults to false for the "smtp" protocol and true for the "smtps" protocol.
      See Also:
    • MAIL_SMTP_SSL_CHECKSERVERIDENTITY

      static final String MAIL_SMTP_SSL_CHECKSERVERIDENTITY
      If set to true, 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 to false.
      See Also:
    • MAIL_SMTP_SSL_TRUST

      static final String 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

      static final String 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

      static final StartTLSOption 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

      @NotNull static @NotNull MailConfig create()
      Creates a new instance of MailConfig.
      Returns:
      a new MailConfig instance.
    • getProperties

      @NotNull @NotNull Properties getProperties()
      Gets the mail properties.
      Returns:
      a Properties object containing mail properties
    • isMailDebug

      boolean isMailDebug()
      Checks if mail debugging is enabled.
      Returns:
      true if mail debugging is enabled, false otherwise
    • setMailDebug

      MailConfig setMailDebug(boolean mailDebug)
      Sets the mail debugging option.
      Parameters:
      mailDebug - true to enable mail debugging, false to disable it
      Returns:
      the updated MailConfig instance for method chaining
    • getMailSmtpUser

      String getMailSmtpUser()
      Gets the SMTP user.
      Returns:
      the SMTP user as a string
    • setMailSmtpUser

      MailConfig setMailSmtpUser(String mailSmtpUser)
      Sets the SMTP user.
      Parameters:
      mailSmtpUser - the SMTP user to set
      Returns:
      the updated MailConfig instance for method chaining
    • getMailSmtpHost

      String getMailSmtpHost()
      Gets the SMTP host.
      Returns:
      the SMTP host
    • setMailSmtpHost

      MailConfig setMailSmtpHost(String mailSmtpHost)
      Sets the SMTP host.
      Parameters:
      mailSmtpHost - the SMTP host to set
      Returns:
      the updated MailConfig instance for method chaining
    • getMailSmtpPort

      int getMailSmtpPort()
      Gets the SMTP port.
      Returns:
      the SMTP port
    • setMailSmtpPort

      MailConfig setMailSmtpPort(int mailSmtpPort)
      Sets the SMTP port.
      Parameters:
      mailSmtpPort - the SMTP port to set
      Returns:
      the updated MailConfig instance for method chaining
    • getMailSmtpConnectionTimeout

      int getMailSmtpConnectionTimeout()
      Gets the SMTP connection timeout.
      Returns:
      the SMTP connection timeout in milliseconds
    • setMailSmtpConnectionTimeout

      MailConfig setMailSmtpConnectionTimeout(int mailSmtpConnectionTimeout)
      Sets the SMTP connection timeout.
      Parameters:
      mailSmtpConnectionTimeout - the SMTP connection timeout in milliseconds
      Returns:
      the updated MailConfig instance for method chaining
    • getMailSmtpTimeout

      int getMailSmtpTimeout()
      Gets the SMTP timeout.
      Returns:
      the SMTP timeout in milliseconds
    • setMailSmtpTimeout

      MailConfig setMailSmtpTimeout(int mailSmtpTimeout)
      Sets the SMTP timeout.
      Parameters:
      mailSmtpTimeout - the SMTP timeout in milliseconds
      Returns:
      the updated MailConfig instance for method chaining
    • isMailSmtpAuth

      boolean isMailSmtpAuth()
      Checks if SMTP authentication is enabled.
      Returns:
      true if SMTP authentication is enabled, false otherwise
    • setMailSmtpAuth

      MailConfig setMailSmtpAuth(boolean mailSmtpAuth)
      Sets the SMTP authentication option.
      Parameters:
      mailSmtpAuth - true to enable SMTP authentication, false to disable
      Returns:
      the updated MailConfig instance for method chaining
    • getMailSmtpAuthMechanisms

      String getMailSmtpAuthMechanisms()
      Gets the SMTP authentication mechanisms.
      Returns:
      a string representing the SMTP authentication mechanisms
    • setMailSmtpAuthMechanisms

      MailConfig setMailSmtpAuthMechanisms(String mailSmtpAuthMechanisms)
      Sets the SMTP authentication mechanisms.
      Parameters:
      mailSmtpAuthMechanisms - the SMTP authentication mechanisms to set
      Returns:
      the updated MailConfig instance for method chaining
    • isMailSmtpAuthLoginDisable

      boolean isMailSmtpAuthLoginDisable()
      Checks if the "AUTH LOGIN" command is disabled.
      Returns:
      true if the "AUTH LOGIN" command is disabled, false otherwise
    • setMailSmtpAuthLoginDisable

      MailConfig setMailSmtpAuthLoginDisable(boolean mailSmtpAuthLoginDisable)
      Sets the option to disable the "AUTH LOGIN" command.
      Parameters:
      mailSmtpAuthLoginDisable - true to disable the "AUTH LOGIN" command, false to enable
      Returns:
      the updated MailConfig instance for method chaining
    • isMailSmtpAuthPlainDisable

      boolean isMailSmtpAuthPlainDisable()
      Checks if the "AUTH PLAIN" command is disabled.
      Returns:
      true if the "AUTH PLAIN" command is disabled, false otherwise
    • setMailSmtpAuthPlainDisable

      MailConfig setMailSmtpAuthPlainDisable(boolean mailSmtpAuthPlainDisable)
      Sets the option to disable the "AUTH PLAIN" command.
      Parameters:
      mailSmtpAuthPlainDisable - true to disable the "AUTH PLAIN" command, false to enable
      Returns:
      the updated MailConfig instance for method chaining
    • isMailSmtpAuthDigestMd5Disable

      boolean isMailSmtpAuthDigestMd5Disable()
      Checks if the "AUTH DIGEST-MD5" command is disabled.
      Returns:
      true if the "AUTH DIGEST-MD5" command is disabled, false otherwise
    • setMailSmtpAuthDigestMd5Disable

      MailConfig setMailSmtpAuthDigestMd5Disable(boolean mailSmtpAuthDigestMd5Disable)
      Sets the option to disable the "AUTH DIGEST-MD5" command.
      Parameters:
      mailSmtpAuthDigestMd5Disable - true to disable the "AUTH DIGEST-MD5" command, false to enable
      Returns:
      the updated MailConfig instance for method chaining
    • isMailSmtpAuthXOAuth2Disable

      boolean isMailSmtpAuthXOAuth2Disable()
      Checks if the "AUTH XOAUTH2" command is disabled.
      Returns:
      true if the "AUTH XOAUTH2" command is disabled, false otherwise
    • setMailSmtpAuthXOAuth2Disable

      MailConfig setMailSmtpAuthXOAuth2Disable(boolean mailSmtpAuthXOAuth2Disable)
      Sets the option to disable the "AUTH XOAUTH2" command.
      Parameters:
      mailSmtpAuthXOAuth2Disable - true to disable the "AUTH XOAUTH2" command, false to enable
      Returns:
      the updated MailConfig instance for method chaining
    • getMailSmtpStartTLS

      StartTLSOption getMailSmtpStartTLS()
      Gets the STARTTLS option.
      Returns:
      the STARTTLS option
    • setMailSmtpStartTLS

      MailConfig setMailSmtpStartTLS(StartTLSOption mailSmtpStarttls)
      Sets the STARTTLS option.
      Parameters:
      mailSmtpStarttls - the STARTTLS option to set
      Returns:
      the updated MailConfig instance for method chaining
    • isMailSmtpSslEnable

      boolean isMailSmtpSslEnable()
      Checks if SSL is enabled for SMTP.
      Returns:
      true if SSL is enabled, false otherwise
    • setMailSmtpSslEnable

      MailConfig setMailSmtpSslEnable(boolean mailSmtpSslEnable)
      Sets the option to enable SSL for SMTP.
      Parameters:
      mailSmtpSslEnable - true to enable SSL, false to disable
      Returns:
      the updated MailConfig instance for method chaining
    • isMailSmtpSslCheckServerIdentity

      boolean isMailSmtpSslCheckServerIdentity()
      Checks if the server identity is checked for SMTP SSL.
      Returns:
      true if the server identity is checked, false otherwise
    • setMailSmtpSslCheckServerIdentity

      MailConfig setMailSmtpSslCheckServerIdentity(boolean mailSmtpSslCheckServerIdentity)
      Sets the option to check the server identity for SMTP SSL.
      Parameters:
      mailSmtpSslCheckServerIdentity - true to check the server identity, false to disable
      Returns:
      the updated MailConfig instance for method chaining
    • getMailSmtpSslTrust

      String getMailSmtpSslTrust()
      Gets the SMTP SSL trust setting.
      Returns:
      a string representing the SMTP SSL trust setting
    • setMailSmtpSslTrust

      MailConfig setMailSmtpSslTrust(String mailSmtpSslTrust)
      Sets the SMTP SSL trust setting.
      Parameters:
      mailSmtpSslTrust - the SMTP SSL trust setting to set
      Returns:
      the updated MailConfig instance for method chaining