com.ibm.openpages.api.application

## Class EmailUtil

- java.lang.Object
- - com.ibm.openpages.api.application.EmailUtil

-     public class EmailUtil
      extends java.lang.Object

  A public API that sends out email by using SMTP server. 1. Default mode: will use internal SMTP service. No authentication required. 2. Secure mode: will use security SMTP service. Requires user authentication. The email settings are setup in the registry under /Applications/Common/Email

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `EmailUtil()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `connect(EmailOptions options)`
    `static void` | `defaultSendEmail(java.lang.String from, java.lang.String recipients, java.lang.String subject, java.lang.String body, boolean ignoreError)` This method sends out an email by using an internal SMTP service.
    `static java.lang.String` | `getFromAddress()`
    `static java.lang.String` | `getServer()`
    `static void` | `secureSendEmail(java.lang.String from, java.lang.String recipients, java.lang.String subject, java.lang.String body, boolean ignoreError, java.lang.String secureType, java.lang.String encryptedUsername, java.lang.String encryptedPassword, java.lang.String port)` This method sends out email by using a secured SMTP services.
    `static void` | `sendEmail(EmailOptions options)` Send email
    `static void` | `sendEmail(java.lang.String from, java.lang.String recipients, java.lang.String subjectTextKey, java.lang.Object[] subjectParams, java.lang.String bodyKey, java.lang.Object[] bodyParams, boolean ignoreError, Context context, java.lang.StringBuffer linkBuffer, java.util.Locale locale)` Send email by using OpenPages Application Strings.
    `static void` | `sendEmailBySecuredServer(java.lang.String from, java.lang.String recipients, java.lang.String subjectTextKey, java.lang.Object[] subjectParams, java.lang.String bodyKey, java.lang.Object[] bodyParams, boolean ignoreError, Context context, java.lang.String secureType, java.lang.String username, java.lang.String password, java.lang.String port, java.lang.StringBuffer linkBuffer, java.util.Locale locale)` Send out emails by using a secured SMTP server and gets Subject and Body from OpenPages application string.
    `static void` | `validateEmailSvr()` This validates that the email server was properly configured and is active

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

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### EmailUtil

          public EmailUtil()

  - ### Method Detail

    - #### connect

          public static void connect(EmailOptions options)
                              throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### getServer

          public static java.lang.String getServer()

    - #### getFromAddress

          public static java.lang.String getFromAddress()

    - #### sendEmail

          public static void sendEmail(EmailOptions options)
                                throws java.lang.Exception

      Send email
      Parameters:
        `options` - the email options.
      Throws:
        `java.lang.Exception`

    - #### sendEmail

          public static void sendEmail(java.lang.String from,
                                       java.lang.String recipients,
                                       java.lang.String subjectTextKey,
                                       java.lang.Object[] subjectParams,
                                       java.lang.String bodyKey,
                                       java.lang.Object[] bodyParams,
                                       boolean ignoreError,
                                       Context context,
                                       java.lang.StringBuffer linkBuffer,
                                       java.util.Locale locale)
                                throws java.lang.Exception

      Send email by using OpenPages Application Strings.
      Parameters:
        `from` - (required) the email address identifies where this email was sent from.
        `recipients` - (required) the email address which will receive the email. Could be a comma separated string for multiple recipients.
        `subjectTextKey` - the key is used to locate the application string for subject.
        `subjectParams` - parameters that will be formated into subject text.
        `bodyKey` - the key is used to locate the application string for body.
        `bodyParams` - parameters that will be formated into body text.
        `ignoreError` - (required) Boolean value identifies whether to continue sending email when an error occurred.
        `context` - (required) API context
        `linkBuffer` - the StringBuffer for a URL that points to the object in OpenPages with Watson.
        `locale` - used to get translated application texts for subject and body.
      Throws:
        `java.lang.Exception`

    - #### sendEmailBySecuredServer

          public static void sendEmailBySecuredServer(java.lang.String from,
                                                      java.lang.String recipients,
                                                      java.lang.String subjectTextKey,
                                                      java.lang.Object[] subjectParams,
                                                      java.lang.String bodyKey,
                                                      java.lang.Object[] bodyParams,
                                                      boolean ignoreError,
                                                      Context context,
                                                      java.lang.String secureType,
                                                      java.lang.String username,
                                                      java.lang.String password,
                                                      java.lang.String port,
                                                      java.lang.StringBuffer linkBuffer,
                                                      java.util.Locale locale)
                                               throws java.lang.Exception

      Send out emails by using a secured SMTP server and gets Subject and Body from OpenPages application string.
      Parameters:
        `from` - (required) the email address identifies where this email was sent from.
        `recipients` - (required) the email address which will receive the email. Could be a comma separated string for multiple recipients.
        `subjectTextKey` - the key is used to locate the application string for subject.
        `subjectParams` - parameters that will be formated into subject text.
        `bodyKey` - the key is used to locate the application string for body.
        `bodyParams` - parameters that will be formated into body text.
        `ignoreError` - (required) Boolean value identifies whether to continue sending email when an error occurred.
        `context` - (required) API context
        `secureType` - (required) the security type of the SMTP server. Now supports SSL and TLS.
        `username` - user name for authenticating into the SMTP server. Default use value from registry setting "/OpenPages/Applications/Common/Email/SMTP User Name".
        `password` - password for authenticating into the SMTP server. Default use value from registry setting "/OpenPages/Applications/Common/Email/SMTP Password".
        `port` - the port number identifies the secured server port. Default port for SSL is 465. Default port for TLS is 587.
        `linkBuffer` - the StringBuffer for a URL that points to the object in OpenPages with Watson.
        `locale` - used to get translated application texts for subject and body.
      Throws:
        `java.lang.Exception`

    - #### defaultSendEmail

          public static void defaultSendEmail(java.lang.String from,
                                              java.lang.String recipients,
                                              java.lang.String subject,
                                              java.lang.String body,
                                              boolean ignoreError)
                                       throws java.lang.Exception

      This method sends out an email by using an internal SMTP service. No authentication is required.
      Parameters:
        `from` - (required) the email address identifies where this email was sent from.
        `recipients` - (required) the email address which will receive the email. Could be a comma separated string for multiple recipients.
        `subject` - (required) the subject of the email
        `body` - (required) the body of the email
        `ignoreError` - (required) Boolean value identifies whether to continue sending email when an error occurred.
      Throws:
        `java.lang.Exception`

    - #### secureSendEmail

          public static void secureSendEmail(java.lang.String from,
                                             java.lang.String recipients,
                                             java.lang.String subject,
                                             java.lang.String body,
                                             boolean ignoreError,
                                             java.lang.String secureType,
                                             java.lang.String encryptedUsername,
                                             java.lang.String encryptedPassword,
                                             java.lang.String port)
                                      throws java.lang.Exception

      This method sends out email by using a secured SMTP services. User authentication is required.
      Parameters:
        `from` - (required) the email address identifies where this email come from.
        `recipients` - (required) the email address which will receive the email. Could be a comma separated string for multiple recipients.
        `subject` - (required) the subject of the email.
        `body` - (required) the body of the email.
        `ignoreError` - (required) Boolean value identifies whether to continue sending email when an error occurred.
        `secureType` - (required) the security type of the SMTP server. Now supports SSL and TLS.
        `encryptedUsername` - user name for authenticating into the SMTP server. Default use value from registry setting "/OpenPages/Applications/Common/Email/SMTP User Name".
        `encryptedPassword` - password for authenticating into the SMTP server. Default use value from registry setting "/OpenPages/Applications/Common/Email/SMTP Password".
        `port` - the port number identifies the secured server port. Default port for SSL is 465. Default port for TLS is 587.
      Throws:
        `java.lang.Exception`

    - #### validateEmailSvr

          public static void validateEmailSvr()
                                       throws java.lang.Exception

      This validates that the email server was properly configured and is active
      Throws:
        `java.lang.Exception` - if the email server is not properly configured
      Since:
        8.2.0.1

Licensed Materials - Property of IBM
OpenPages with Watson (PID: 5725-D51)
© Copyright IBM Corporation 2013, 2022. All Rights Reserved.
US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.