Package adams.core.net
Class EmailHelper
- java.lang.Object
-
- adams.core.net.EmailHelper
-
public class EmailHelper extends Object
A helper class for emails.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_ADDRESS_FROMThe default "from" email address.static StringDEFAULT_SENDEMAILThe default "send email".static StringDEFAULT_SIGNATUREThe default "signature".static StringENABLEDWhether Email support is enabled.static StringFILENAMEthe name of the props file.protected static Propertiesm_Propertiesthe properties.static StringSIGNATURE_SEPARATORthe separator between body and signature.static StringSMTP_PASSWORDThe password the SMTP server.static StringSMTP_PORTThe SMTP port.static StringSMTP_PROTOCOLSThe protocols to use, e.g.static StringSMTP_REQUIRES_AUTHENTICATIONWhether authentication is necessary.static StringSMTP_SERVERThe SMTP server.static StringSMTP_START_TLSWhether STARTTLS is necessary.static StringSMTP_TIMEOUTThe timeout for the SMTP server.static StringSMTP_USE_SSLWhether to use SSL.static StringSMTP_USERThe user for the SMTP server.static StringSUPPORT_EMAILThe support email address.
-
Constructor Summary
Constructors Constructor Description EmailHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Stringcombine(String body, String signature)Combines body and signature, but only if the signatures is neither null nor empty.static StringgetDefaultFromAddress()Returns the default FROM address.static AbstractSendEmailgetDefaultSendEmail()Returns the default send email class.static StringgetDefaultSignature()Returns the default signature.static PropertiesgetProperties()Returns the underlying properties.static BasePasswordgetSmtpPassword()Returns the SMTP password.static intgetSmtpPort()Returns the SMTP port.static StringgetSmtpProtocols()Returns the protocols to use (eg "TLSv1.2").static booleangetSmtpRequiresAuthentication()Returns whether the server requires authentication.static StringgetSmtpServer()Returns the SMTP server.static booleangetSmtpStartTLS()Returns whether to start TLS.static intgetSmtpTimeout()Returns the timeout (in msecs) for the server.static StringgetSmtpUser()Returns the SMTP user.static booleangetSmtpUseSSL()Returns whether to use SSL.static StringgetSupportEmail()Returns the email address for the support.static booleanisEnabled()Returns whether email support has been enabled.static booleanwriteProperties()Writes the specified properties to disk.static booleanwriteProperties(Properties props)Writes the specified properties to disk.
-
-
-
Field Detail
-
FILENAME
public static final String FILENAME
the name of the props file.- See Also:
- Constant Field Values
-
ENABLED
public static final String ENABLED
Whether Email support is enabled.- See Also:
- Constant Field Values
-
SMTP_SERVER
public static final String SMTP_SERVER
The SMTP server.- See Also:
- Constant Field Values
-
SMTP_PORT
public static final String SMTP_PORT
The SMTP port.- See Also:
- Constant Field Values
-
SMTP_REQUIRES_AUTHENTICATION
public static final String SMTP_REQUIRES_AUTHENTICATION
Whether authentication is necessary.- See Also:
- Constant Field Values
-
SMTP_START_TLS
public static final String SMTP_START_TLS
Whether STARTTLS is necessary.- See Also:
- Constant Field Values
-
SMTP_USE_SSL
public static final String SMTP_USE_SSL
Whether to use SSL.- See Also:
- Constant Field Values
-
SMTP_PROTOCOLS
public static final String SMTP_PROTOCOLS
The protocols to use, e.g. "TLSv1.2".- See Also:
- Constant Field Values
-
SMTP_USER
public static final String SMTP_USER
The user for the SMTP server.- See Also:
- Constant Field Values
-
SMTP_PASSWORD
public static final String SMTP_PASSWORD
The password the SMTP server.- See Also:
- Constant Field Values
-
SMTP_TIMEOUT
public static final String SMTP_TIMEOUT
The timeout for the SMTP server.- See Also:
- Constant Field Values
-
DEFAULT_ADDRESS_FROM
public static final String DEFAULT_ADDRESS_FROM
The default "from" email address.- See Also:
- Constant Field Values
-
DEFAULT_SIGNATURE
public static final String DEFAULT_SIGNATURE
The default "signature".- See Also:
- Constant Field Values
-
DEFAULT_SENDEMAIL
public static final String DEFAULT_SENDEMAIL
The default "send email".- See Also:
- Constant Field Values
-
SUPPORT_EMAIL
public static final String SUPPORT_EMAIL
The support email address.- See Also:
- Constant Field Values
-
SIGNATURE_SEPARATOR
public static final String SIGNATURE_SEPARATOR
the separator between body and signature.- See Also:
- Constant Field Values
-
m_Properties
protected static Properties m_Properties
the properties.
-
-
Method Detail
-
getProperties
public static Properties getProperties()
Returns the underlying properties.- Returns:
- the properties
-
writeProperties
public static boolean writeProperties()
Writes the specified properties to disk.- Returns:
- true if successfully stored
-
writeProperties
public static boolean writeProperties(Properties props)
Writes the specified properties to disk.- Parameters:
props- the properties to write to disk- Returns:
- true if successfully stored
-
isEnabled
public static boolean isEnabled()
Returns whether email support has been enabled.- Returns:
- true if enabled
-
getSmtpServer
public static String getSmtpServer()
Returns the SMTP server.- Returns:
- the server
-
getSmtpPort
public static int getSmtpPort()
Returns the SMTP port.- Returns:
- the port
-
getSmtpStartTLS
public static boolean getSmtpStartTLS()
Returns whether to start TLS.- Returns:
- true if to start TLS
-
getSmtpProtocols
public static String getSmtpProtocols()
Returns the protocols to use (eg "TLSv1.2").- Returns:
- the protocols, empty if default
-
getSmtpUseSSL
public static boolean getSmtpUseSSL()
Returns whether to use SSL.- Returns:
- true if to use SSL
-
getSmtpRequiresAuthentication
public static boolean getSmtpRequiresAuthentication()
Returns whether the server requires authentication.- Returns:
- true if authentication required
-
getSmtpTimeout
public static int getSmtpTimeout()
Returns the timeout (in msecs) for the server.- Returns:
- the timeout
-
getSmtpUser
public static String getSmtpUser()
Returns the SMTP user.- Returns:
- the user
-
getSmtpPassword
public static BasePassword getSmtpPassword()
Returns the SMTP password.- Returns:
- the password
-
getDefaultFromAddress
public static String getDefaultFromAddress()
Returns the default FROM address.- Returns:
- the default address
-
getDefaultSignature
public static String getDefaultSignature()
Returns the default signature.- Returns:
- the default signature (back quoted)
- See Also:
Utils.backQuoteChars(String)
-
getDefaultSendEmail
public static AbstractSendEmail getDefaultSendEmail()
Returns the default send email class.- Returns:
- the default class
-
getSupportEmail
public static String getSupportEmail()
Returns the email address for the support.- Returns:
- the email address, if any
-
-