Package de.hybris.platform.util.mail
Class MailUtils
java.lang.Object
de.hybris.platform.util.mail.MailUtils
Utilities class for simplifying sending of E-Mails with commons
mail API.
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.apache.commons.mail.EmailCreates a mail using the commons mail API and initializes it with all mail parameters from the project.properties file.static voidvalidateEmailAddress(String address, String type) Validates a mail address for correctness.static voidvalidateEmailServer(String server) Validates given server name for emptiness.static voidvalidateParameter(String parameter, String type) Validates a single parameter of the e-mail settings for emptiness.static voidvalidatePop3(String popServer, String popUser, String popPwd) Validates pop3 settings for emptiness (server and user, password can be empty).
-
Method Details
-
validateEmailServer
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 checkpopUser- user name to checkpopPwd- 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 checktype- 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 checktype- 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.EmailExceptionCreates 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
-