Mailer (Apache Ant API)
Date: 2018-09-11

Package org.apache.tools.ant.taskdefs.email

## Class Mailer

- java.lang.Object
- - org.apache.tools.ant.taskdefs.email.Mailer

- Direct Known Subclasses:
    `MimeMailer`

      public abstract class Mailer
      extends java.lang.Object

  Base class for the various emailing implementations.
  Since:
    Ant 1.5

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected java.util.Vector<EmailAddress>` | `bccList` |
    `protected java.util.Vector<EmailAddress>` | `ccList` |
    `protected java.util.Vector<java.io.File>` | `files` |
    `protected EmailAddress` | `from` |
    `protected java.util.Vector<Header>` | `headers` |
    `protected java.lang.String` | `host` |
    `protected boolean` | `includeFileNames` |
    `protected Message` | `message` |
    `protected java.lang.String` | `password` |
    `protected int` | `port` |
    `protected java.util.Vector<EmailAddress>` | `replyToList` |
    `protected boolean` | `SSL` |
    `protected java.lang.String` | `subject` |
    `protected Task` | `task` |
    `protected java.util.Vector<EmailAddress>` | `toList` |
    `protected java.lang.String` | `user` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `Mailer()` |

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `protected java.lang.String` | `getDate()` | Return the current Date in a format suitable for a SMTP date header.
    `protected boolean` | `isPortExplicitlySpecified()` | Whether the port has been explicitly specified by the user.
    `protected boolean` | `isStartTLSEnabled()` |
    `abstract void` | `send()` | Send the email.
    `void` | `setBccList​(java.util.Vector<EmailAddress> list)` | Set the bcc addresses.
    `void` | `setCcList​(java.util.Vector<EmailAddress> list)` | Set the cc addresses.
    `void` | `setEnableStartTLS​(boolean b)` | Set whether to allow authentication to switch to a TLS connection via STARTTLS.
    `void` | `setFiles​(java.util.Vector<java.io.File> files)` | Set the files to attach.
    `void` | `setFrom​(EmailAddress from)` | Set the address to send from.
    `void` | `setHeaders​(java.util.Vector<Header> v)` | Set the generic headers to add to the email.
    `void` | `setHost​(java.lang.String host)` | Set the mail server.
    `void` | `setIgnoreInvalidRecipients​(boolean b)` | Whether invalid recipients should be ignored (but a warning will be logged) instead of making the task fail.
    `void` | `setIncludeFileNames​(boolean b)` | Indicate whether filenames should be listed in the body.
    `void` | `setMessage​(Message m)` | Set the message.
    `void` | `setPassword​(java.lang.String password)` | Set the password for smtp auth.
    `void` | `setPort​(int port)` | Set the smtp port.
    `void` | `setPortExplicitlySpecified​(boolean explicit)` | Whether the port has been explicitly specified by the user.
    `void` | `setReplyToList​(java.util.Vector<EmailAddress> list)` | Set the replyTo addresses.
    `void` | `setSSL​(boolean ssl)` | Set whether to send the mail through SSL.
    `void` | `setSubject​(java.lang.String subject)` | Set the subject.
    `void` | `setTask​(Task task)` | Set the owning task.
    `void` | `setToList​(java.util.Vector<EmailAddress> list)` | Set the to addresses.
    `void` | `setUser​(java.lang.String user)` | Set the user for smtp auth.
    `protected boolean` | `shouldIgnoreInvalidRecipients()` | Whether invalid recipients should be ignored.

    - ### Methods inherited from class java.lang.Object

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

- - ### Field Detail

    - #### host

          protected java.lang.String host

    - #### port

          protected int port

    - #### user

          protected java.lang.String user

    - #### password

          protected java.lang.String password

    - #### SSL

          protected boolean SSL

    - #### message

          protected Message message

    - #### from

          protected EmailAddress from

    - #### replyToList

          protected java.util.Vector<EmailAddress> replyToList

    - #### toList

          protected java.util.Vector<EmailAddress> toList

    - #### ccList

          protected java.util.Vector<EmailAddress> ccList

    - #### bccList

          protected java.util.Vector<EmailAddress> bccList

    - #### files

          protected java.util.Vector<java.io.File> files

    - #### subject

          protected java.lang.String subject

    - #### task

          protected Task task

    - #### includeFileNames

          protected boolean includeFileNames

    - #### headers

          protected java.util.Vector<Header> headers

  - ### Constructor Detail

    - #### Mailer

          public Mailer()

  - ### Method Detail

    - #### setHost

          public void setHost​(java.lang.String host)

      Set the mail server.
      Parameters:
        `host` - the mail server name.

    - #### setPort

          public void setPort​(int port)

      Set the smtp port.
      Parameters:
        `port` - the SMTP port.

    - #### setPortExplicitlySpecified

          public void setPortExplicitlySpecified​(boolean explicit)

      Whether the port has been explicitly specified by the user.
      Parameters:
        `explicit` - boolean
      Since:
        Ant 1.8.2

    - #### isPortExplicitlySpecified

          protected boolean isPortExplicitlySpecified()

      Whether the port has been explicitly specified by the user.
      Returns:
        boolean
      Since:
        Ant 1.8.2

    - #### setUser

          public void setUser​(java.lang.String user)

      Set the user for smtp auth.
      Parameters:
        `user` - the username.
      Since:
        Ant 1.6

    - #### setPassword

          public void setPassword​(java.lang.String password)

      Set the password for smtp auth.
      Parameters:
        `password` - the authentication password.
      Since:
        Ant 1.6

    - #### setSSL

          public void setSSL​(boolean ssl)

      Set whether to send the mail through SSL.
      Parameters:
        `ssl` - if true use SSL transport.
      Since:
        Ant 1.6

    - #### setEnableStartTLS

          public void setEnableStartTLS​(boolean b)

      Set whether to allow authentication to switch to a TLS connection via STARTTLS.
      Parameters:
        `b` - boolean; if true STARTTLS will be supported.
      Since:
        Ant 1.8.0

    - #### isStartTLSEnabled

          protected boolean isStartTLSEnabled()

    - #### setMessage

          public void setMessage​(Message m)

      Set the message.
      Parameters:
        `m` - the message content.

    - #### setFrom

          public void setFrom​(EmailAddress from)

      Set the address to send from.
      Parameters:
        `from` - the sender.

    - #### setReplyToList

          public void setReplyToList​(java.util.Vector<EmailAddress> list)

      Set the replyTo addresses.
      Parameters:
        `list` - a vector of replyTo addresses.
      Since:
        Ant 1.6

    - #### setToList

          public void setToList​(java.util.Vector<EmailAddress> list)

      Set the to addresses.
      Parameters:
        `list` - a vector of recipient addresses.

    - #### setCcList

          public void setCcList​(java.util.Vector<EmailAddress> list)

      Set the cc addresses.
      Parameters:
        `list` - a vector of cc addresses.

    - #### setBccList

          public void setBccList​(java.util.Vector<EmailAddress> list)

      Set the bcc addresses.
      Parameters:
        `list` - a vector of the bcc addresses.

    - #### setFiles

          public void setFiles​(java.util.Vector<java.io.File> files)

      Set the files to attach.
      Parameters:
        `files` - list of files to attach to the email.

    - #### setSubject

          public void setSubject​(java.lang.String subject)

      Set the subject.
      Parameters:
        `subject` - the subject line.

    - #### setTask

          public void setTask​(Task task)

      Set the owning task.
      Parameters:
        `task` - the owning task instance.

    - #### setIncludeFileNames

          public void setIncludeFileNames​(boolean b)

      Indicate whether filenames should be listed in the body.
      Parameters:
        `b` - if true list attached file names in the body content.

    - #### setHeaders

          public void setHeaders​(java.util.Vector<Header> v)

      Set the generic headers to add to the email.
      Parameters:
        `v` - a Vector presumed to contain Header objects.
      Since:
        Ant 1.7

    - #### send

          public abstract void send()
                             throws BuildException

      Send the email.
      Throws:
        `BuildException` - if the email can't be sent.

    - #### setIgnoreInvalidRecipients

          public void setIgnoreInvalidRecipients​(boolean b)

      Whether invalid recipients should be ignored (but a warning will be logged) instead of making the task fail.

      Even with this property set to true the task will still fail if the mail couldn't be sent to any recipient at all.

      Parameters:
        `b` - boolean
      Since:
        Ant 1.8.0

    - #### shouldIgnoreInvalidRecipients

          protected boolean shouldIgnoreInvalidRecipients()

      Whether invalid recipients should be ignored.
      Returns:
        boolean
      Since:
        Ant 1.8.0

    - #### getDate

          protected final java.lang.String getDate()

      Return the current Date in a format suitable for a SMTP date header.
      Returns:
        the current date in SMTP suitable format.
      Since:
        Ant 1.5