Class SMTPConnection

java.lang.Object
com.mirth.connect.server.userutil.SMTPConnection

public class SMTPConnection extends Object
Used to send e-mail messages.
  • Constructor Details

    • SMTPConnection

      public SMTPConnection(String host, String port, int socketTimeout, boolean useAuthentication, String secure, String username, String password, String from)
      Instantiates an SMTP connection used to send e-mail messages with.
      Parameters:
      host - The SMTP server address.
      port - The SMTP server port (e.g. 25, 587, 465).
      socketTimeout - The socket connection timeout value in milliseconds.
      useAuthentication - Determines whether authentication is needed for the SMTP server.
      secure - The encryption security layer to use for the SMTP connection ("TLS" or "SSL"). If left blank, no encryption layer will be used.
      username - If authentication is required, the username to authenticate with.
      password - If authentication is required, the password to authenticate with.
      from - The FROM field to use for dispatched e-mail messages.
    • SMTPConnection

      public SMTPConnection(String host, String port, boolean useAuthentication, String secure, String username, String password, String from)
      Instantiates an SMTP connection used to send e-mail messages with.
      Parameters:
      host - The SMTP server address.
      port - The SMTP server port (e.g. 25, 587, 465).
      useAuthentication - Determines whether authentication is needed for the SMTP server.
      secure - The encryption security layer to use for the SMTP connection ("TLS" or "SSL"). If left blank, no encryption layer will be used.
      username - If authentication is required, the username to authenticate with.
      password - If authentication is required, the password to authenticate with.
      from - The FROM field to use for the e-mail.
  • Method Details

    • getHost

      public String getHost()
      Returns the SMTP server address.
      Returns:
      The SMTP server address.
    • setHost

      public void setHost(String host)
      Sets the SMTP server address.
      Parameters:
      host - The SMTP server address to use.
    • getPort

      public String getPort()
      Returns the SMTP server port.
      Returns:
      The SMTP server port.
    • setPort

      public void setPort(String port)
      Sets the SMTP server port.
      Parameters:
      port - The SMTP server port to use (e.g. 25, 587, 465).
    • isUseAuthentication

      public boolean isUseAuthentication()
      Returns true if authentication is needed for the SMTP server, otherwise returns false.
      Returns:
      true if authentication is needed for the SMTP server, otherwise returns false.
    • setUseAuthentication

      public void setUseAuthentication(boolean useAuthentication)
      Sets whether authentication is needed for the SMTP server.
      Parameters:
      useAuthentication - Determines whether authentication is needed for the SMTP server.
    • getSecure

      public String getSecure()
      Returns the encryption security layer being used for the SMTP connection (e.g "TLS" or "SSL").
      Returns:
      The encryption security layer being used for the SMTP connection (e.g "TLS" or "SSL").
    • setSecure

      public void setSecure(String secure)
      Sets the encryption security layer to use for the SMTP connection.
      Parameters:
      secure - The encryption security layer to use for the SMTP connection ("TLS" or "SSL"). If left blank, no encryption layer will be used.
    • getUsername

      public String getUsername()
      Returns the username being used to authenticate to the SMTP server.
      Returns:
      The username being used to authenticate to the SMTP server.
    • setUsername

      public void setUsername(String username)
      Sets the username to use to authenticate to the SMTP server.
      Parameters:
      username - The username to authenticate with.
    • getPassword

      public String getPassword()
      Returns the password being used to authenticate to the SMTP server.
      Returns:
      The password being used to authenticate to the SMTP server.
    • setPassword

      public void setPassword(String password)
      Sets the password to use to authenticate to the SMTP server.
      Parameters:
      password - The password to authenticate with.
    • getFrom

      public String getFrom()
      Returns the FROM field being used for dispatched e-mail messages.
      Returns:
      The FROM field being used for dispatched e-mail messages.
    • setFrom

      public void setFrom(String from)
      Sets the FROM field to use for dispatched e-mail messages.
      Parameters:
      from - The FROM field to use for dispatched e-mail messages.
    • getSocketTimeout

      public int getSocketTimeout()
      Returns the socket connection timeout value in milliseconds.
      Returns:
      The socket connection timeout value in milliseconds.
    • setSocketTimeout

      public void setSocketTimeout(int socketTimeout)
      Sets the socket connection timeout value.
      Parameters:
      socketTimeout - The socket connection timeout value in milliseconds.
    • send

      public void send(String toList, String ccList, String from, String subject, String body, String charset) throws org.apache.commons.mail.EmailException
      Sends an e-mail message.
      Parameters:
      toList - A string representing a list of e-mail addresses to send the message to (separated by ",").
      ccList - A string representing a list of e-mail addresses to copy the message to (separated by ",").
      from - The FROM field to use for the e-mail message.
      subject - The subject of the e-mail message.
      body - The content of the e-mail message.
      charset - The charset encoding to use when sending the e-mail message.
      Throws:
      org.apache.commons.mail.EmailException - If an error occurred while sending the e-mail message.
    • send

      public void send(String toList, String ccList, String from, String subject, String body) throws org.apache.commons.mail.EmailException
      Sends an e-mail message.
      Parameters:
      toList - A string representing a list of e-mail addresses to send the message to (separated by ",").
      ccList - A string representing a list of e-mail addresses to copy the message to (separated by ",").
      from - The FROM field to use for the e-mail message.
      subject - The subject of the e-mail message.
      body - The content of the e-mail message.
      Throws:
      org.apache.commons.mail.EmailException - If an error occurred while sending the e-mail message.
    • send

      public void send(String toList, String ccList, String subject, String body) throws org.apache.commons.mail.EmailException
      Sends an e-mail message.
      Parameters:
      toList - A string representing a list of e-mail addresses to send the message to (separated by ",").
      ccList - A string representing a list of e-mail addresses to copy the message to (separated by ",").
      subject - The subject of the e-mail message.
      body - The content of the e-mail message.
      Throws:
      org.apache.commons.mail.EmailException - If an error occurred while sending the e-mail message.