Class MailUtils

java.lang.Object
de.hybris.platform.util.mail.MailUtils

public final class MailUtils extends Object
Utilities class for simplifying sending of E-Mails with commons mail API.
  • Method Details

    • validateEmailServer

      public static void validateEmailServer(String server) throws org.apache.commons.mail.EmailException
      Validates given server name for emptiness.
      Parameters:
      server - name to validate
      Throws:
      org.apache.commons.mail.EmailException - name is empty
    • validatePop3

      public static void validatePop3(String popServer, String popUser, String popPwd) throws org.apache.commons.mail.EmailException
      Validates pop3 settings for emptiness (server and user, password can be empty).
      Parameters:
      popServer - server name to check
      popUser - user name to check
      popPwd - pwd to check
      Throws:
      org.apache.commons.mail.EmailException - server or user or both are empty
    • validateParameter

      public static void validateParameter(String parameter, String type) throws org.apache.commons.mail.EmailException
      Validates a single parameter of the e-mail settings for emptiness.
      Parameters:
      parameter - parameter to check
      type - name of parameter type for announcing in exception
      Throws:
      org.apache.commons.mail.EmailException - parameter was empty
    • validateEmailAddress

      public static void validateEmailAddress(String address, String type) throws org.apache.commons.mail.EmailException
      Validates a mail address for correctness. The following kind of errors are checked:
      • missing text before '@' (for example: &040;domain.de)
      • missing text between '@' and domain (for example: address@.de)
      • missing domain (for example: address@domain.)
      • missing '@' (for example: addressatdomain.de)
      • missing domain separator (for example: address@domaindotde)
      Parameters:
      address - address to check
      type - name of address type for announcing in exception
      Throws:
      org.apache.commons.mail.EmailException - address was not valid
    • getPreConfiguredEmail

      public static org.apache.commons.mail.Email getPreConfiguredEmail() throws org.apache.commons.mail.EmailException
      Creates a mail using the commons mail API and initializes it with all mail parameters from the project.properties file.
      Returns:
      new email configured with default values from project.properties
      Throws:
      org.apache.commons.mail.EmailException - error while email creation