Class Emailer

All Implemented Interfaces:
DynamicMBean, MBeanRegistration, BaseObjectNamed, EmailerMBean, SelfEmailingMBean

public final class Emailer extends SelfAwareMBean implements EmailerMBean
This MBean acts as an e-mailing utility service for other MBeans and provides centralized configuration of MBean e-mailing.

Supported API: true

Extendable: false
  • Method Details

    • getInstance

      public static Emailer getInstance(StandardMBean mbeanContext, boolean throwExceptionOnNoInstance)
      Return the Emailer associated by MBeanLoader with 'mbeanContext' or the Emailer started and still not stopped within this classloader.

      Supported API: true
      Parameters:
      mbeanContext - MBean to use as a lookup context for the given MBean (currently ignored unless SelfAwareMBean)
      throwExceptionOnNoInstance - Whether a NullPointerException should be thrown when no started instance is available
    • sendEmailToAddressesOrList

      public void sendEmailToAddressesOrList(String addressesOrEmailList, String subject, Emailer.EmailContentProvider contents) throws IllegalArgumentException
      Send e-mail to an e-mail address or list

      Supported API: true
      Parameters:
      addressesOrEmailList - List of e-mail addresses or name of e-mail list to send e-mail to
      subject - Subject of e-mail
      contents - Contents of e-mail
      Throws:
      IllegalArgumentException
    • sendEmail

      public void sendEmail(String toEmailAddresses, String subject, Emailer.EmailContentProvider contents) throws IllegalArgumentException
      Send e-mail to a list of e-mail addresses

      Supported API: true
      Parameters:
      toEmailAddresses - List of e-mail addresses to send e-mail to
      subject - Subject of e-mail
      contents - Contents of e-mail
      Throws:
      IllegalArgumentException
    • sendEmailToList

      public void sendEmailToList(String toEmailListName, String subject, Emailer.EmailContentProvider contents) throws IllegalArgumentException
      Send e-mail to e-mail list

      Supported API: true
      Parameters:
      toEmailListName - E-mail list to send e-mail to
      subject - Subject of e-mail
      contents - Contents of e-mail
      Throws:
      IllegalArgumentException
    • sendEmail

      public void sendEmail(jakarta.mail.internet.InternetAddress[] recipients, String subject, Emailer.EmailContentProvider contents) throws IllegalArgumentException
      Send e-mail to array of e-mail addresses

      Supported API: true
      Parameters:
      recipients - Array of e-mail addresses to send e-mail to
      subject - Subject of e-mail
      contents - Contents of e-mail
      Throws:
      IllegalArgumentException
    • sendEmail

      public void sendEmail(jakarta.mail.internet.InternetAddress[] recipients, String subject, Emailer.EmailContentProvider contents, String fromAddress) throws IllegalArgumentException
      Send e-mail to array of e-mail addresses

      Supported API: true
      Parameters:
      recipients - Array of e-mail addresses to send e-mail to
      subject - Subject of e-mail
      contents - Contents of e-mail
      fromAddress - From address for this e-mail; will use FromAddress attribute if this is null/unspecified
      Throws:
      IllegalArgumentException - if recipients is null, empty, or unacceptable to jakarta.mail
    • emailZipOfFiles

      public void emailZipOfFiles(URL baseURL, URL[] urls, String addressesOrEmailList, String subject) throws IOException
      E-mail zip of files.

      Supported API: true
      Parameters:
      baseURL - Base URL which jar entry names are formed relative to, must be parent URL to all other URLs specified
      urls - URLs of files
      addressesOrEmailList - List of e-mail addresses or name of e-mail list to send e-mail to
      subject - Subject to give e-mail
      Throws:
      IOException
    • emailTextFile

      public void emailTextFile(File file, String addressesOrEmailList, String subject, long maxLines, long maxChars) throws IOException
      E-mail last portion of text file

      Supported API: true
      Parameters:
      file - File to e-mail
      addressesOrEmailList - List of e-mail addresses or name of e-mail list to send e-mail to
      subject - Subject to give e-mail
      maxLines - Maximum number of lines to include; non-positive numbers imply no limit
      maxChars - Maximum number of characters to include; non-positive numbers imply no limit
      Throws:
      IOException