public class EmailUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.util.regex.Pattern |
EMAIL_REGEXP
This pattern can be used to find email addresses.
|
private static boolean |
enabled |
private static java.lang.String |
hostName |
private static int |
hostPort |
private static boolean |
initialized |
private static java.lang.String |
senderEmail |
private static java.lang.String |
senderName |
private static boolean |
ssl |
private static boolean |
tls |
Constructor and Description |
---|
EmailUtil() |
Modifier and Type | Method and Description |
---|---|
static org.apache.commons.mail.Email |
createSimpleEmail()
Create a simple text email.
|
static void |
init() |
static boolean |
isEnabled()
Check if email sending has been enabled for the server or not.
|
static boolean |
isEnabled(User user)
Check if email sending is enabled for the given user.
|
static boolean |
isValidEmail(java.lang.String email)
Checks if the given string looks like an email address.
|
static void |
unload()
Unload all settings.
|
public static final java.util.regex.Pattern EMAIL_REGEXP
private static boolean initialized
private static boolean enabled
private static java.lang.String hostName
private static int hostPort
private static boolean ssl
private static boolean tls
private static java.lang.String senderEmail
private static java.lang.String senderName
public static void init()
public static void unload()
public static boolean isEnabled()
init()
method hasn't been called, the server admin hasn't
specified an outgoing smtp server or an outgoing sender email.public static boolean isEnabled(User user)
isEnabled()
).
User.getSendMessagesAsEmail()
).
user
- The user to checkpublic static boolean isValidEmail(java.lang.String email)
EMAIL_REGEXP
pattern.email
- The string to checkEMAIL_REGEXP
public static org.apache.commons.mail.Email createSimpleEmail() throws org.apache.commons.mail.EmailException
org.apache.commons.mail.EmailException
- If there is something wrong with the setup