Class EmailHelper


  • public class EmailHelper
    extends Object
    A helper class for emails.
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    • Constructor Detail

      • EmailHelper

        public EmailHelper()
    • 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
      • combine

        public static String combine​(String body,
                                     String signature)
        Combines body and signature, but only if the signatures is neither null nor empty.
        Parameters:
        body - the actual body of the email
        signature - the signature to add, ignored if null or empty
        Returns:
        the extended body