Apache Ant TasksMailMailDescription 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 <attachments> elements, which are path-like structures. This means any filesystem based resource or resource collection can be used to point to attachments. Prior to Apache Ant 1.7 only <fileset> has been supported as a nested element, you can still use this directly without an <attachments> container. 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 blind 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 | ignoreInvalidRecipients | Boolean. Whether the task should try to send the message to as many recipients as possible and should only fail if neither is reachable. Since Ant 1.8.0. | No, default is false | enableStartTLS | "true", "on" or "yes" accepted here whether the STARTTLS command used to switch to an encrypted connection for authentication should be supported. Requires JavaMail. Since Ant 1.8.0 | No | Note regarding the attributes containing email addressesSince Ant 1.6, the attributes from, replyto, tolist, cclist, bcclistcan contain email addresses of the form :You need to enter the angle brackets as XML entities> and < . Parameters specified as nested elementsto / 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 | messageSpecifies the message to include in the email body. It takes the followingattributes: 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 addedinside the <message> element. Property expansion will occurin the message, whether it is specified as an external file or as text withinthe <message> element. headerSince Ant 1.7, arbitrary mail headers can be added by specifying these attributes on one or more nested header elements: Attribute | Description | Required | name | The name associated with this mail header. | Yes | value | The value to assign to this mail header. | Yes | It is permissible to duplicate the name attribute amongst multiple headers. Examples<mail from="me" tolist="you" subject="Results of nightly build" files="build.log"/>
Sends an email from me to you with a subject ofResults of nightly build and includes the contents of the filebuild.log in the body of the message. <mail mailhost="smtp.myisp.com" mailport="1025" subject="Test build"> <from address="[email protected]"/> <replyto address="[email protected]"/> <to address="[email protected]"/> <message>The ${buildname} nightly build has completed</message> <attachments> <fileset dir="dist"> <include name="**/*.zip"/> </fileset> </attachments></mail>
Sends an eMail from [email protected] to [email protected] with a subject ofTest Build. Replies to this email will go to [email protected].Any zip files from the dist directory are attached. Thetask will attempt to use JavaMail and fall back to UU encoding or no encoding inthat 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="[email protected]" mailport="25" subject="Test build" charset="utf-8"> <from address="[email protected]"/> <to address="[email protected]"/> <message>some international text:${line2}</message></mail>
Sends an eMail from [email protected] to [email protected] with a subject ofTest Build, the message body being coded in UTF-8 |