MailLogger (Apache Ant API)
Description: declaration: package: org.apache.tools.ant.listener, class: MailLogger

# Class MailLogger

java.lang.Object
org.apache.tools.ant.DefaultLogger
org.apache.tools.ant.listener.MailLogger

All Implemented Interfaces:
  `EventListener, BuildListener, BuildLogger`

public class MailLogger extends DefaultLogger
Buffers log messages from DefaultLogger, and sends an e-mail with the results. The following Project properties are used to send the mail.

- MailLogger.mailhost [default: localhost] - Mail server to use
- MailLogger.port [default: 25] - Default port for SMTP
- MailLogger.user [no default] - user name for SMTP auth (requires Java or Jakarta Mail)
- MailLogger.password [no default] - password for SMTP auth (requires Java or Jakarta Mail)
- MailLogger.ssl [default: false] - on or true if ssl is needed (requires Java or Jakarta Mail)
- MailLogger.from [required] - Mail "from" address
- MailLogger.from [no default] - Mail "replyto" address(es), comma-separated
- MailLogger.failure.notify [default: true] - Send build failure e-mails?
- MailLogger.success.notify [default: true] - Send build success e-mails?
- MailLogger.failure.to [required if failure mail to be sent] - Address to send failure messages to
- MailLogger.success.to [required if success mail to be sent] - Address to send success messages to
- MailLogger.failure.cc [no default] - Address to send failure messages to carbon copy (cc)
- MailLogger.success.to [no default] - Address to send success messages to carbon copy (cc)
- MailLogger.failure.bcc [no default] - Address to send failure messages to blind carbon copy (bcc)
- MailLogger.success.bcc [no default] - Address to send success messages to blind carbon copy (bcc)
- MailLogger.failure.subject [default: "Build Failure"] - Subject of failed build
- MailLogger.success.subject [default: "Build Success"] - Subject of successful build
- MailLogger.failure.body [default: none] - fixed text of mail body for a failed build, default is to send the logfile
- MailLogger.success.body [default: none] - fixed text of mail body for a successful build, default is to send the logfile
- MailLogger.mimeType [default: text/plain] - MIME-Type of email
- MailLogger.charset [no default] - character set of email
- MailLogger.starttls.enable [default: false] - on or true if STARTTLS should be supported (requires Java or Jakarta Mail)
- MailLogger.starttls.require [default: false] - on or true if STARTTLS should be required (requires Java or Jakarta Mail)
- MailLogger.tls.checkserveridentity [default: true] - on or true if the identity of the server shall be chcked during the TLS handshake (requires Java or Jakarta Mail)
- MailLogger.properties.file [no default] - Filename of properties file that will override other values.

These properties are set using standard Ant property setting mechanisms (<property>, command-line -D, etc). Ant properties can be overridden by specifying the filename of a properties file in the MailLogger.properties.file property . Any properties defined in that file will override Ant properties.

- ## Field Summary

  ### Fields inherited from class DefaultLogger

  `emacsMode, err, LEFT_COLUMN_SIZE, lSep, msgOutputLevel, out`
  Modifier and Type
  Field
  Description
  `protected boolean`
  `emacsMode`
  Whether or not to use emacs-style output
  `protected PrintStream`
  `err`
  PrintStream to write error messages to
  `static final int`
  `LEFT_COLUMN_SIZE`
  Size of left-hand column for right-justified task name.
  `protected static final String`
  `lSep`
  Deprecated.
  `protected int`
  `msgOutputLevel`
  Lowest level of message to write out
  `protected PrintStream`
  `out`
  PrintStream to write non-error messages to

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MailLogger()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `buildFinished(BuildEvent event)`
  Sends an e-mail with the log results.
  `protected void`
  `log(String message)`
  Receives and buffers log messages.

  ### Methods inherited from class DefaultLogger

  `buildStarted, extractProjectName, formatTime, getBuildFailedMessage, getBuildSuccessfulMessage, getMessageOutputLevel, getTimestamp, messageLogged, printMessage, setEmacsMode, setErrorPrintStream, setMessageOutputLevel, setOutputPrintStream, targetFinished, targetStarted, taskFinished, taskStarted`
  Modifier and Type
  Method
  Description
  `void`
  `buildStarted(BuildEvent event)`
  Responds to a build being started by just remembering the current time.
  `protected String`
  `extractProjectName(BuildEvent event)`
  Get the project name or null
  `protected static String`
  `formatTime(long millis)`
  Convenience method to format a specified length of time.
  `protected String`
  `getBuildFailedMessage()`
  This is an override point: the message that indicates whether a build failed.
  `protected String`
  `getBuildSuccessfulMessage()`
  This is an override point: the message that indicates that a build succeeded.
  `int`
  `getMessageOutputLevel()`
  `protected String`
  `getTimestamp()`
  Get the current time.
  `void`
  `messageLogged(BuildEvent event)`
  Logs a message, if the priority is suitable.
  `protected void`
  `printMessage(String message, PrintStream stream, int priority)`
  Prints a message to a PrintStream.
  `void`
  `setEmacsMode(boolean emacsMode)`
  Sets this logger to produce emacs (and other editor) friendly output.
  `void`
  `setErrorPrintStream(PrintStream err)`
  Sets the output stream to which this logger is to send error messages.
  `void`
  `setMessageOutputLevel(int level)`
  Sets the highest level of message this logger should respond to.
  `void`
  `setOutputPrintStream(PrintStream output)`
  Sets the output stream to which this logger is to send its output.
  `void`
  `targetFinished(BuildEvent event)`
  No-op implementation.
  `void`
  `targetStarted(BuildEvent event)`
  Logs a message to say that the target has started if this logger allows information-level messages.
  `void`
  `taskFinished(BuildEvent event)`
  No-op implementation.
  `void`
  `taskStarted(BuildEvent event)`
  No-op implementation.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### MailLogger

    public MailLogger()

- ## Method Details

  - ### buildFinished

    public void buildFinished(BuildEvent event)
    Sends an e-mail with the log results.
    Specified by:
      `buildFinished` in interface `BuildListener`
    Overrides:
      `buildFinished` in class `DefaultLogger`
    Parameters:
      `event` - the build finished event
    See Also:
      - `BuildEvent.getException()`

  - ### log

    protected void log(String message)
    Receives and buffers log messages.
    Overrides:
      `log` in class `DefaultLogger`
    Parameters:
      `message` - the message being logger