## Mail

### Description

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.

Note: This task may depend on external libraries that are not included in the Ant distribution. See Library Dependencies for more information.

### Parameters

Attribute | Description | Required
from | Email address of sender. | Either a `from` attribute, or a `<from>` element.
tolist | Comma-separated list of recipients. | At least one of these, or the equivalent elements.
cclist | Comma-separated list of recipients to carbon copy
bcclist | Comma-separated list of recipients to carbon copy
message | Message to send in the body of the email. | One of these or a `<message>` element.
messagefile | File to send as the body of the email. Property values in the file will be expanded.
| messagemimetype | The content type of the message. The default is `text/plain`. | No
files | Files to send as attachments to the email. Separate multiple file names using a comma or space. You can also use `<fileset>` elements to specify files. | No
failonerror | flag to indicate whether to halt the build on any error. The default value is `true`. | No.
includefilenames | Include filename(s) before file contents. Valid only when the `plain` encoding is used. The default value is `false`. | No
mailhost | Host name of the SMTP server. The default value is `localhost`. | No
mailport | TCP port of the SMTP server. The default value is 25. | No
encoding | Specifies the encoding to use for the content of the email. Values are `mime`, `uu`, `plain`, or `auto`. The default value is `auto`. | No
subject | Email subject line. | No

### Parameters specified as nested elements

#### to / cc / bcc / from

Adds an email address element. It takes the following attributes:

Attribute | Description | Required
name | The display name for the address. | No
address | The email address. | Yes

#### message

Specifies the message to include in the email body. It takes the following attributes:

Attribute | Description | Required
src | The file to use as the message. | No
mimetype | The content type to use for the message. | No

If the `src` attribute is not specified, then text can be added inside the `<message>` element. Property expansion will occur in the message, whether it is specified as an external file or as text within the `<message>` element.

### Examples

>     <mail from="me"
>           tolist="you"
>           subject="Results of nightly build"
>           files="build.log"/>

Sends an email from me to you with a subject of Results of nightly build and includes the contents of the file build.log in the body of the message.

>     <mail mailhost="smtp.myisp.com" mailport="1025" subject="Test build">
>       <from address="me@myisp.com"/>
>       <to address="all@xyz.com"/>
>       <message>The ${buildname} nightly build has completed</message>
>       <fileset dir="dist">
>         <includes name="**/*.zip"/>
>       </fileset>
>     </mail>

Sends an eMail from me@myisp.com to all@xyz.com with a subject of Test Build and attaches any zip files from the dist directory. The task will attempt to use JavaMail and fall back to UU encoding or no encoding in that order depending on what support classes are available. `${buildname}` will be replaced with the `buildname` property's value.

Copyright © 2000-2003 Apache Software Foundation. All rights Reserved.