Class SimpleMailer


  • public class SimpleMailer
    extends Object
    Reads emails stored in files and sends them.
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    • Field Detail

      • m_DebugLevel

        protected int m_DebugLevel
        the debugging level (0 = off, >0 = on).
      • m_RegExp

        protected BaseRegExp m_RegExp
        the expression to use for listing the files.
      • m_SuccessfulSuffix

        protected String m_SuccessfulSuffix
        the suffix for the successfully sent emails.
      • m_FailedSuffix

        protected String m_FailedSuffix
        the suffix for the emails that couldn't be sent.
    • Constructor Detail

      • SimpleMailer

        public SimpleMailer()
    • Method Detail

      • setDebugLevel

        public void setDebugLevel​(int value)
        Sets the debugging level (0 = off).
        Parameters:
        value - >0 if debugging output should be printed
      • getDebugLevel

        public int getDebugLevel()
        Returns the debugging level (0 = turned off).
        Returns:
        true if debugging output is on
      • debugLevelTipText

        public String debugLevelTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • isDebugOn

        protected boolean isDebugOn()
        Returns true if debugging output is turned on (any level).
        Returns:
        true if debugging output is turned on
      • debug

        protected void debug​(String msg)
        Processes the debugging message.
        Parameters:
        msg - the debugging message to process
      • debug

        protected void debug​(String msg,
                             int level)
        Processes the debugging message.
        Parameters:
        level - the debugging level
        msg - the debugging message to process
      • setReader

        public void setReader​(EmailFileReader value)
        Sets the reader for the email files.
        Parameters:
        value - the reader
      • getReader

        public EmailFileReader getReader()
        Returns the reader for the email files.
        Returns:
        the reader
      • readerTipText

        public String readerTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setWatchDir

        public void setWatchDir​(PlaceholderDirectory value)
        Sets the directory to watch.
        Parameters:
        value - the directory
      • getWatchDir

        public PlaceholderDirectory getWatchDir()
        Returns the directory to watch.
        Returns:
        the directory
      • watchDirTipText

        public String watchDirTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setRegExp

        public void setRegExp​(BaseRegExp value)
        Sets the regular expression to match the files against.
        Parameters:
        value - the regular expression
      • getRegExp

        public BaseRegExp getRegExp()
        Returns the regular expression to match the files against.
        Returns:
        the regular expression
      • regExpTipText

        public String regExpTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setSendEmail

        public void setSendEmail​(AbstractSendEmail value)
        Sets the send email scheme to use.
        Parameters:
        value - the send email
      • getSendEmail

        public AbstractSendEmail getSendEmail()
        Returns the send email scheme in use.
        Returns:
        the send email
      • sendEmailTipText

        public String sendEmailTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setSuccessfulSuffix

        public void setSuccessfulSuffix​(String value)
        Sets the suffix for successfully sent emails.
        Parameters:
        value - the suffix (incl dot)
      • getSuccessfulSuffix

        public String getSuccessfulSuffix()
        Returns the suffix for successfully sent emails.
        Returns:
        the suffix (incl dot)
      • successfulSuffixTipText

        public String successfulSuffixTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setFailedSuffix

        public void setFailedSuffix​(String value)
        Sets the suffix for emails that couldn't get sent.
        Parameters:
        value - the suffix (incl dot)
      • getFailedSuffix

        public String getFailedSuffix()
        Returns the suffix for emails that couldn't get sent.
        Returns:
        the suffix (incl dot)
      • failedSuffixTipText

        public String failedSuffixTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • list

        protected String[] list()
        Lists the files in the watch directory.
        Returns:
        the files that matched
      • execute

        public void execute()
        Locates and sends the emails.
      • runMailer

        public static void runMailer​(String[] options)
        Runs the mailer from the commandline.
        Parameters:
        options - the commandline options
      • main

        public static void main​(String[] args)
        For running the mailer from command-line. Use "-env classname" to define the environment class. Default is Environment.
        Parameters:
        args - the command-line arguments, use -h/-help to display them