Class MailUtil

java.lang.Object
jp.ecuacion.lib.core.util.MailUtil

public class MailUtil extends Object
Provides mail-related utility methods.
  • Method Details

    • sendErrorMail

      public static void sendErrorMail(@RequireNonnull Throwable throwable)
      Sends an error mail.

      This is used in exception handler to notify system administrator the occurence of an error.

      The mail is sent to the addresses defined in application.properties with key jp.ecuacion.lib.core.mail.address-csv-on-system-error.

      Parameters:
      throwable - throwable
    • sendErrorMail

      public static void sendErrorMail(@RequireNonnull Throwable throwable, @Nullable String additionalMessage)
      Sends an error mail adding an additional message to it.
      Parameters:
      throwable - throwable.
      additionalMessage - additional message, may be null if no additionalMessage is needed. In the case of null no additional message is output.
    • sendWarnMail

      @Nonnull public static void sendWarnMail(@Nullable String content, @RequireNonnull List<String> mailToList)
      Sends a warn mail.
      Parameters:
      content - content, may be null if no mailbody content needed.
      mailToList - list of mailadresses used for "TO" address
    • sendTextMail

      public static void sendTextMail(@Nullable List<String> mailToList, @Nullable List<String> mailCcList, @RequireNonnull String title, @Nullable String content) throws Exception
      Provides sending text-format mail function.

      The following settings ars needed to application.properties to send mails with this object.

      # true or false
      SMTP_AUTHENTICATION=true
      #Normally "true" if the port number is 465, "false" if 587
      SMTP_SSL_ENABLED=true
      jp.ecuacion.lib.core.mail.smtp.server=smtp.gmail.com
      jp.ecuacion.lib.core.mail.smtp.port=465
      jp.ecuacion.lib.core.mail.smtp.sender=info@ecuacion.jp
      jp.ecuacion.lib.core.mail.smtp.password=(password)
      jp.ecuacion.lib.core.mail.title-prefix=[app-name: staging environment]
      jp.ecuacion.lib.core.mail.address-csv-on-system-error=info@ecuacion.jp
      
      Parameters:
      mailToList - mailToList. Either mailToList or mailCcList need to have at least one element.
      mailCcList - mailCcList. Either mailToList or mailCcList need to have at least one element.
      title - title
      content - content, may be null if no content needed.
      Throws:
      Exception - Exception
    • sendHtmlMail

      public static void sendHtmlMail(@Nullable List<String> mailToList, @Nullable List<String> mailCcList, @RequireNonnull String title, @Nullable String content) throws Exception
      Provides sending html-format mail function.
      Throws:
      Exception
      See Also: