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

# Class SendEmail

java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
org.apache.tools.ant.taskdefs.email.EmailTask
org.apache.tools.ant.taskdefs.SendEmail

All Implemented Interfaces:
  `Cloneable`

public class SendEmail extends EmailTask
A task to send SMTP email. This task can send mail using either plain text, UU encoding or Mime format mail depending on what is available. Attachments may be sent using nested FileSet elements.

Since:
  Ant 1.2

- ## Nested Class Summary

  ### Nested classes/interfaces inherited from class EmailTask

  `EmailTask.Encoding`
  Modifier and Type
  Class
  Description
  `static class`
  `EmailTask.Encoding`
  Enumerates the encoding constants.

- ## Field Summary

  ### Fields inherited from class EmailTask

  `AUTO, MIME, PLAIN, UU`
  Modifier and Type
  Field
  Description
  `static final String`
  `AUTO`
  Constant to show that the best available mailer should be used.
  `static final String`
  `MIME`
  Constant to allow the Mime mailer to be requested
  `static final String`
  `PLAIN`
  Constant to allow the plaintext mailer to be requested
  `static final String`
  `UU`
  Constant to allow the UU mailer to be requested

  ### Fields inherited from class Task

  `target, taskName, taskType, wrapper`
  Modifier and Type
  Field
  Description
  `protected Target`
  `target`
  Deprecated.
  since 1.6.x.
  `protected String`
  `taskName`
  Deprecated.
  since 1.6.x.
  `protected String`
  `taskType`
  Deprecated.
  since 1.6.x.
  `protected RuntimeConfigurable`
  `wrapper`
  Deprecated.
  since 1.6.x.

  ### Fields inherited from class ProjectComponent

  `description, location, project`
  Modifier and Type
  Field
  Description
  `protected String`
  `description`
  Deprecated.
  since 1.6.x.
  `protected Location`
  `location`
  Deprecated.
  since 1.6.x.
  `protected Project`
  `project`
  Deprecated.
  since 1.6.x.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SendEmail()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `setMailport(Integer value)`
  Deprecated.
  since 1.5.x.

  ### Methods inherited from class EmailTask

  `addBcc, addCc, addFileset, addFrom, addMessage, addReplyTo, addTo, createAttachments, createHeader, execute, getCharset, getIncludeFileNames, setBccList, setCcList, setCharset, setCheckServerIdentity, setEnableStartTLS, setEncoding, setFailOnError, setFiles, setFrom, setIgnoreInvalidRecipients, setIncludefilenames, setMailhost, setMailport, setMessage, setMessageFile, setMessageFileInputEncoding, setMessageMimeType, setPassword, setReplyTo, setRequireStartTLS, setSSL, setSubject, setToList, setUser`
  Modifier and Type
  Method
  Description
  `void`
  `addBcc(EmailAddress address)`
  Add a "bcc" address element.
  `void`
  `addCc(EmailAddress address)`
  Add a "cc" address element.
  `void`
  `addFileset(FileSet fs)`
  Add a set of files (nested fileset attribute).
  `void`
  `addFrom(EmailAddress address)`
  Add a from address element.
  `void`
  `addMessage(Message message)`
  Add a message element.
  `void`
  `addReplyTo(EmailAddress address)`
  Add a replyto address element.
  `void`
  `addTo(EmailAddress address)`
  Add a to address element.
  `Path`
  `createAttachments()`
  Creates a Path as container for attachments.
  `Header`
  `createHeader()`
  Create a nested header element.
  `void`
  `execute()`
  Send an email.
  `String`
  `getCharset()`
  Returns the character set of mail message.
  `boolean`
  `getIncludeFileNames()`
  Get whether file names should be included.
  `void`
  `setBccList(String list)`
  Shorthand to set the "bcc" address element.
  `void`
  `setCcList(String list)`
  Shorthand to set the "cc" address element.
  `void`
  `setCharset(String charset)`
  Sets the character set of mail message.
  `void`
  `setCheckServerIdentity(boolean b)`
  Whether the server's identity shall be verified during TLS handshake.
  `void`
  `setEnableStartTLS(boolean b)`
  Set whether to allow authentication to switch to a TLS connection via STARTTLS.
  `void`
  `setEncoding(EmailTask.Encoding encoding)`
  Set the preferred encoding method.
  `void`
  `setFailOnError(boolean failOnError)`
  Set whether BuildExceptions should be passed back to the core.
  `void`
  `setFiles(String filenames)`
  Set the list of files to be attached.
  `void`
  `setFrom(String address)`
  Shorthand to set the from address element.
  `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 includeFileNames)`
  Set whether to include filenames.
  `void`
  `setMailhost(String host)`
  Set the host.
  `void`
  `setMailport(int port)`
  Set the mail server port.
  `void`
  `setMessage(String message)`
  Shorthand method to set the message.
  `void`
  `setMessageFile(File file)`
  Shorthand method to set the message from a file.
  `void`
  `setMessageFileInputEncoding(String encoding)`
  Sets the encoding to expect when reading the message from a file.
  `void`
  `setMessageMimeType(String type)`
  Shorthand method to set type of the text message, text/plain by default but text/html or text/xml is quite feasible.
  `void`
  `setPassword(String password)`
  Set the password for SMTP auth; this requires JavaMail.
  `void`
  `setReplyTo(String address)`
  Shorthand to set the replyto address element.
  `void`
  `setRequireStartTLS(boolean b)`
  Set whether to require authentication to switch to a TLS connection via STARTTLS.
  `void`
  `setSSL(boolean ssl)`
  Set whether to send data over SSL.
  `void`
  `setSubject(String subject)`
  Set the subject line of the email.
  `void`
  `setToList(String list)`
  Shorthand to set the "to" address element.
  `void`
  `setUser(String user)`
  Set the user for SMTP auth; this requires JavaMail.

  ### Methods inherited from class Task

  `bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType`
  Modifier and Type
  Method
  Description
  `final void`
  `bindToOwner(Task owner)`
  Bind a task to another; use this when configuring a newly created task to do work on behalf of another.
  `Target`
  `getOwningTarget()`
  Returns the container target of this task.
  `RuntimeConfigurable`
  `getRuntimeConfigurableWrapper()`
  Returns the wrapper used for runtime configuration.
  `String`
  `getTaskName()`
  Returns the name to use in logging messages.
  `String`
  `getTaskType()`
  Return the type of task.
  `protected RuntimeConfigurable`
  `getWrapper()`
  Return the runtime configurable structure for this task.
  `protected void`
  `handleErrorFlush(String output)`
  Handles an error line by logging it with the WARN priority.
  `protected void`
  `handleErrorOutput(String output)`
  Handles an error output by logging it with the WARN priority.
  `protected void`
  `handleFlush(String output)`
  Handles output by logging it with the INFO priority.
  `protected int`
  `handleInput(byte[] buffer, int offset, int length)`
  Handle an input request by this task.
  `protected void`
  `handleOutput(String output)`
  Handles output by logging it with the INFO priority.
  `void`
  `init()`
  Called by the project to let the task initialize properly.
  `protected final boolean`
  `isInvalid()`
  Has this task been marked invalid?
  `void`
  `log(String msg)`
  Logs a message with the default (INFO) priority.
  `void`
  `log(String msg, int msgLevel)`
  Logs a message with the given priority.
  `void`
  `log(String msg, Throwable t, int msgLevel)`
  Logs a message with the given priority.
  `void`
  `log(Throwable t, int msgLevel)`
  Logs a message with the given priority.
  `void`
  `maybeConfigure()`
  Configures this task - if it hasn't been done already.
  `final void`
  `perform()`
  Performs this task if it's still valid, or gets a replacement version and performs that otherwise.
  `void`
  `reconfigure()`
  Force the task to be reconfigured from its RuntimeConfigurable.
  `void`
  `setOwningTarget(Target target)`
  Sets the target container of this task.
  `void`
  `setRuntimeConfigurableWrapper(RuntimeConfigurable wrapper)`
  Sets the wrapper to be used for runtime configuration.
  `void`
  `setTaskName(String name)`
  Sets the name to use in logging messages.
  `void`
  `setTaskType(String type)`
  Sets the name with which the task has been invoked.

  ### Methods inherited from class ProjectComponent

  `clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject`
  Modifier and Type
  Method
  Description
  `Object`
  `clone()`
  `String`
  `getDescription()`
  Returns the description of the current action.
  `Location`
  `getLocation()`
  Returns the file/location where this task was defined.
  `Project`
  `getProject()`
  Returns the project to which this component belongs.
  `void`
  `setDescription(String desc)`
  Sets a description of the current action.
  `void`
  `setLocation(Location location)`
  Sets the file/location where this task was defined.
  `void`
  `setProject(Project project)`
  Sets the project object of this component.

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### SendEmail

    public SendEmail()

- ## Method Details

  - ### setMailport

    @Deprecated public void setMailport(Integer value)
    Deprecated.
    since 1.5.x. Use `EmailTask.setMailport(int)` instead.
    Sets the mailport parameter of this build task.
    Parameters:
      `value` - mail port name.