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 int
m_DebugLevel
the debugging level (0 = off, >0 = on).protected String
m_FailedSuffix
the suffix for the emails that couldn't be sent.protected EmailFileReader
m_Reader
the email reader to use.protected BaseRegExp
m_RegExp
the expression to use for listing the files.protected AbstractSendEmail
m_SendEmail
for sending the mail.protected String
m_SuccessfulSuffix
the suffix for the successfully sent emails.protected PlaceholderDirectory
m_WatchDir
the 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 void
debug(String msg)
Processes the debugging message.protected void
debug(String msg, int level)
Processes the debugging message.String
debugLevelTipText()
Returns the tip text for this property.void
execute()
Locates and sends the emails.String
failedSuffixTipText()
Returns the tip text for this property.int
getDebugLevel()
Returns the debugging level (0 = turned off).String
getFailedSuffix()
Returns the suffix for emails that couldn't get sent.EmailFileReader
getReader()
Returns the reader for the email files.BaseRegExp
getRegExp()
Returns the regular expression to match the files against.AbstractSendEmail
getSendEmail()
Returns the send email scheme in use.String
getSuccessfulSuffix()
Returns the suffix for successfully sent emails.PlaceholderDirectory
getWatchDir()
Returns the directory to watch.protected boolean
isDebugOn()
Returns true if debugging output is turned on (any level).protected String[]
list()
Lists the files in the watch directory.static void
main(String[] args)
For running the mailer from command-line.String
readerTipText()
Returns the tip text for this property.String
regExpTipText()
Returns the tip text for this property.static void
runMailer(String[] options)
Runs the mailer from the commandline.String
sendEmailTipText()
Returns the tip text for this property.void
setDebugLevel(int value)
Sets the debugging level (0 = off).void
setFailedSuffix(String value)
Sets the suffix for emails that couldn't get sent.void
setReader(EmailFileReader value)
Sets the reader for the email files.void
setRegExp(BaseRegExp value)
Sets the regular expression to match the files against.void
setSendEmail(AbstractSendEmail value)
Sets the send email scheme to use.void
setSuccessfulSuffix(String value)
Sets the suffix for successfully sent emails.void
setWatchDir(PlaceholderDirectory value)
Sets the directory to watch.String
successfulSuffixTipText()
Returns the tip text for this property.String
watchDirTipText()
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
-
-