io.vertx.ext.mail

## Class MailConfig

- java.lang.Object
- - io.vertx.ext.mail.MailConfig

-     public class MailConfig
      extends Object

  represents the configuration of a mail service with mail server hostname, port, security options, login options and login/password
  Author:
    Alexander Lehmann

- - ### Constructor Summary

    Constructors
    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

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `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.
    `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` | `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` | `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` | `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` | `setUsername(String username)` Set the username for the login.
    `JsonObject` | `toJson()` convert config object to Json representation

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### MailConfig

          public MailConfig()

      construct a config object with default options

    - #### MailConfig

          public MailConfig(String hostname)

      construct a config object with hostname and default options
      Parameters:
        `hostname` - the hostname of the mail server

    - #### MailConfig

          public MailConfig(String hostname,
                            int port)

      construct a config object with hostname/port and default options
      Parameters:
        `hostname` - the hostname of the mail server
        `port` - the port of the mail server

    - #### MailConfig

          public MailConfig(String hostname,
                            int port,
                            StartTLSOptions starttls,
                            LoginOption login)

      construct a config object with hostname/port and security and login options
      Parameters:
        `hostname` - the hostname of the mail server
        `port` - the port of the mail server
        `starttls` - whether to use TLS or not
        `login` - whether to use Login or not

    - #### MailConfig

          public MailConfig(MailConfig other)

      copy config object from another MailConfig object
      Parameters:
        `other` - the object to be copied

    - #### MailConfig

          public MailConfig(JsonObject config)

      construct config object from Json representation
      Parameters:
        `config` - the config to copy

  - ### Method Detail

    - #### getHostname

          public String getHostname()

      get the hostname of the mailserver
      Returns:
        hostname

    - #### setHostname

          public MailConfig setHostname(String hostname)

      Set the hostname of the smtp server.
      Parameters:
        `hostname` - the hostname (default is localhost)
      Returns:
        a reference to this, so the API can be used fluently

    - #### getPort

          public int getPort()

      get the port of the mailserver
      Returns:
        port

    - #### setPort

          public MailConfig setPort(int port)

      Set the port of the smtp server.
      Parameters:
        `port` - the port (default is 25)
      Returns:
        a reference to this, so the API can be used fluently

    - #### getStarttls

          public StartTLSOptions getStarttls()

      get security (TLS) options
      Returns:
        the security options

    - #### setStarttls

          public MailConfig setStarttls(StartTLSOptions starttls)

      Set the tls security mode for the connection.

      Either NONE, OPTIONAL or REQUIRED

      Parameters:
        `starttls` - (default is OPTIONAL)
      Returns:
        a reference to this, so the API can be used fluently

    - #### getLogin

          public LoginOption getLogin()

      get login options
      Returns:
        the login options

    - #### setLogin

          public MailConfig setLogin(LoginOption login)

      Set the login mode for the connection.

      Either DISABLED, OPTIONAL or REQUIRED

      Parameters:
        `login` - (default is OPTIONAL)
      Returns:
        a reference to this, so the API can be used fluently

    - #### getUsername

          public String getUsername()

      get username
      Returns:
        username

    - #### setUsername

          public MailConfig setUsername(String username)

      Set the username for the login.
      Parameters:
        `username` - the username
      Returns:
        a reference to this, so the API can be used fluently

    - #### getPassword

          public String getPassword()

      get password
      Returns:
        password

    - #### setPassword

          public MailConfig setPassword(String password)

      Set the password for the login.
      Parameters:
        `password` - the password
      Returns:
        a reference to this, so the API can be used fluently

    - #### isSsl

          public boolean isSsl()

      get whether ssl is used on connect
      Returns:
        ssl option

    - #### setSsl

          public MailConfig setSsl(boolean ssl)

      Set the sslOnConnect mode for the connection.
      Parameters:
        `ssl` - true is ssl is used
      Returns:
        a reference to this, so the API can be used fluently

    - #### isTrustAll

          public boolean isTrustAll()

      get whether to trust all certificates on ssl connect
      Returns:
        trustAll option

    - #### setTrustAll

          public MailConfig setTrustAll(boolean trustAll)

      set whether to trust all certificates on ssl connect the option is also applied to STARTTLS operation
      Parameters:
        `trustAll` - trust all certificates
      Returns:
        a reference to this, so the API can be used fluently

    - #### getKeyStore

          public String getKeyStore()

      get the key store filename to be used when opening SMTP connections
      Returns:
        the keyStore

    - #### setKeyStore

          public MailConfig setKeyStore(String keyStore)

      get the key store filename to be used when opening SMTP connections

      if not set, an options object will be created based on other settings (ssl and trustAll)

      Parameters:
        `keyStore` - the key store filename to be set
      Returns:
        a reference to this, so the API can be used fluently

    - #### getKeyStorePassword

          public String getKeyStorePassword()

      get the key store password to be used when opening SMTP connections
      Returns:
        the keyStorePassword

    - #### setKeyStorePassword

          public MailConfig setKeyStorePassword(String keyStorePassword)

      get the key store password to be used when opening SMTP connections
      Parameters:
        `keyStorePassword` - the key store passwords to be set
      Returns:
        a reference to this, so the API can be used fluently

    - #### getAuthMethods

          public String getAuthMethods()

      get string of allowed auth methods, if set only these methods will be used if the server supports them. If null or empty all supported methods may be used
      Returns:
        the authMethods

    - #### setAuthMethods

          public MailConfig setAuthMethods(String authMethods)

      set string of allowed auth methods. if set only these methods will be used if the server supports them. If null or empty all supported methods may be used
      Parameters:
        `authMethods` - the authMethods to set
      Returns:
        a reference to this, so the API can be used fluently

    - #### getOwnHostname

          public String getOwnHostname()

      get the hostname to be used for HELO/EHLO and the Message-ID
      Returns:
        my own hostname

    - #### setOwnHostname

          public MailConfig setOwnHostname(String ownHostname)

      set the hostname to be used for HELO/EHLO and the Message-ID
      Parameters:
        `ownHostname` - my own hostname to set
      Returns:
        a reference to this, so the API can be used fluently

    - #### getMaxPoolSize

          public int getMaxPoolSize()

      get the max allowed number of open connections to the mailserver if not set the default is 10
      Returns:
        max pool size value

    - #### setMaxPoolSize

          public MailConfig setMaxPoolSize(int maxPoolSize)

      set the max allowed number of open connections to the mail server if not set the default is 10
      Returns:
        this to be able to use the object fluently

    - #### isKeepAlive

          public boolean isKeepAlive()

      get if connection pool is enabled default is true

      if the connection pooling is disabled, the max number of sockets is enforced nevertheless

      Returns:
        keep alive value

    - #### setKeepAlive

          public MailConfig setKeepAlive(boolean keepAlive)

      set if connection pool is enabled default is true

      if the connection pooling is disabled, the max number of sockets is enforced nevertheless

      Returns:
        this to be able to use the object fluently

    - #### isAllowRcptErrors

          public boolean isAllowRcptErrors()

      get if sending allows rcpt errors (default is false)

      if true, the mail will be sent to the recipients that the server accepted, if any

      Returns:
        the allowRcptErrors

    - #### setAllowRcptErrors

          public MailConfig setAllowRcptErrors(boolean allowRcptErrors)

      set if sending allows rcpt errors

      if true, the mail will be sent to the recipients that the server accepted, if any

      Parameters:
        `allowRcptErrors` - the allowRcptErrors to set (default is false)
      Returns:
        this to be able to use the object fluently

    - #### isDisableEsmtp

          public boolean isDisableEsmtp()

      get if ESMTP should be tried as first command (EHLO) (default is true)

      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.

      Returns:
        the disableEsmtp

    - #### setDisableEsmtp

          public MailConfig setDisableEsmtp(boolean disableEsmtp)

      set if ESMTP should be tried as first command (EHLO)

      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.

      Parameters:
        `disableEsmtp` - the disableEsmtp to set (default is true)
      Returns:
        this to be able to use the object fluently

    - #### toJson

          public JsonObject toJson()

      convert config object to Json representation
      Returns:
        json object of the config

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

Copyright © 2019 Eclipse. All rights reserved.