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.




SMTP auth and SSL/TLS require JavaMail and are only available in MIME format.



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.
replyto Replyto email address. No
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
user user name for SMTP auth Yes, if SMTP auth is required on your SMTP server

the email message will be then sent using Mime and requires JavaMail
password password for SMTP auth Yes, if SMTP auth is required on your SMTP server

the email message will be then sent using Mime and requires JavaMail
ssl "true", "on" or "yes" accepted here

indicates whether you need TLS/SSL
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. uu or plain are not compatible with SMTP auth No
charset Character set of the email.
You can also set the charset in the message nested element.
These options are mutually exclusive.
No
subject Email subject line. No

Note regarding the attributes containing email addresses

Since ant 1.6, the attributes from, replyto, tolist, cclist, bcclist can contain email addresses of the form :

You need to enter the angle brackets as XML entities &gt; and &lt;.

Parameters specified as nested elements

to / cc / bcc / from/ replyto

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
charset Character set of the message
You can also set the charset as attribute of the enclosing mail task.
These options are mutually exclusive.
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="config@myisp.com"/>
  <replyto 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 config@myisp.com to all@xyz.com with a subject of Test Build. Replies to this email will go to me@myisp.com. Any zip files from the dist directory are attached.  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.

<property name="line2" value="some_international_message"/>
<echo message="${line2}"/>

<mail mailhost="somehost@xyz.com" mailport="25" subject="Test build"  charset="utf-8">
  <from address="me@myist.com"/>
  <to address="all@xyz.com" />
  <message>some international text:${line2}</message>
</mail>

Sends an eMail from me@myisp.com to all@xyz.com with a subject of Test Build, the message body being coded in UTF-8


Copyright © 2000-2004 The Apache Software Foundation. All rights Reserved.