Package adams.core.net
Class SimpleMailer
- java.lang.Object
-
- adams.core.net.SimpleMailer
-
public class SimpleMailer extends Object
Reads emails stored in files and sends them.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
-
-
Field Summary
Fields Modifier and Type Field Description protected intm_DebugLevelthe debugging level (0 = off, >0 = on).protected Stringm_FailedSuffixthe suffix for the emails that couldn't be sent.protected EmailFileReaderm_Readerthe email reader to use.protected BaseRegExpm_RegExpthe expression to use for listing the files.protected AbstractSendEmailm_SendEmailfor sending the mail.protected Stringm_SuccessfulSuffixthe suffix for the successfully sent emails.protected PlaceholderDirectorym_WatchDirthe directory to watch.
-
Constructor Summary
Constructors Constructor Description SimpleMailer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddebug(String msg)Processes the debugging message.protected voiddebug(String msg, int level)Processes the debugging message.StringdebugLevelTipText()Returns the tip text for this property.voidexecute()Locates and sends the emails.StringfailedSuffixTipText()Returns the tip text for this property.intgetDebugLevel()Returns the debugging level (0 = turned off).StringgetFailedSuffix()Returns the suffix for emails that couldn't get sent.EmailFileReadergetReader()Returns the reader for the email files.BaseRegExpgetRegExp()Returns the regular expression to match the files against.AbstractSendEmailgetSendEmail()Returns the send email scheme in use.StringgetSuccessfulSuffix()Returns the suffix for successfully sent emails.PlaceholderDirectorygetWatchDir()Returns the directory to watch.protected booleanisDebugOn()Returns true if debugging output is turned on (any level).protected String[]list()Lists the files in the watch directory.static voidmain(String[] args)For running the mailer from command-line.StringreaderTipText()Returns the tip text for this property.StringregExpTipText()Returns the tip text for this property.static voidrunMailer(String[] options)Runs the mailer from the commandline.StringsendEmailTipText()Returns the tip text for this property.voidsetDebugLevel(int value)Sets the debugging level (0 = off).voidsetFailedSuffix(String value)Sets the suffix for emails that couldn't get sent.voidsetReader(EmailFileReader value)Sets the reader for the email files.voidsetRegExp(BaseRegExp value)Sets the regular expression to match the files against.voidsetSendEmail(AbstractSendEmail value)Sets the send email scheme to use.voidsetSuccessfulSuffix(String value)Sets the suffix for successfully sent emails.voidsetWatchDir(PlaceholderDirectory value)Sets the directory to watch.StringsuccessfulSuffixTipText()Returns the tip text for this property.StringwatchDirTipText()Returns the tip text for this property.
-
-
-
Field Detail
-
m_DebugLevel
protected int m_DebugLevel
the debugging level (0 = off, >0 = on).
-
m_Reader
protected EmailFileReader m_Reader
the email reader to use.
-
m_WatchDir
protected PlaceholderDirectory m_WatchDir
the directory to watch.
-
m_RegExp
protected BaseRegExp m_RegExp
the expression to use for listing the files.
-
m_SendEmail
protected AbstractSendEmail m_SendEmail
for sending the mail.
-
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.
-
-
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 levelmsg- 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 isEnvironment.- Parameters:
args- the command-line arguments, use -h/-help to display them
-
-