You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

mail.html 8.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <title>Mail Task</title>
  5. </head>
  6. <body>
  7. <h2><a name="mail">Mail</a></h2>
  8. <h3>Description</h3>
  9. <p>A task to send SMTP email. This task can send mail using either plain
  10. text, UU encoding, or MIME format mail, depending on what is available.
  11. Attachments may be sent using nested
  12. <a href="../CoreTypes/fileset.html">fileset</a> elements.</p>
  13. <p><strong>Note:</strong> This task may depend on external libraries
  14. that are not included
  15. in the Ant distribution. See <a href="../install.html#librarydependencies">
  16. Library Dependencies</a> for more information.
  17. </p>
  18. <h3>Parameters</h3>
  19. <table border="1" cellpadding="2" cellspacing="0">
  20. <tr>
  21. <td valign="top"><b>Attribute</b></td>
  22. <td valign="top"><b>Description</b></td>
  23. <td align="center" valign="top"><b>Required</b></td>
  24. </tr>
  25. <tr>
  26. <td valign="top">from</td>
  27. <td valign="top">Email address of sender.</td>
  28. <td align="center" valign="top">Either a <code>from</code> attribute, or a <code>&lt;from&gt;</code>
  29. element.</td>
  30. </tr>
  31. <tr>
  32. <td valign="top">replyto</td>
  33. <td valign="top">Replyto email address.</td>
  34. <td align="center" valign="top">No</td>
  35. </tr>
  36. <tr>
  37. <td valign="top">tolist</td>
  38. <td valign="top">Comma-separated list of recipients.</td>
  39. <td align="center" valign="middle" rowspan="3">At least one of these, or the
  40. equivalent elements.</td>
  41. </tr>
  42. <tr>
  43. <td valign="top">cclist</td>
  44. <td valign="top">Comma-separated list of recipients to carbon copy</td>
  45. </tr>
  46. <tr>
  47. <td valign="top">bcclist</td>
  48. <td valign="top">Comma-separated list of recipients to carbon copy</td>
  49. </tr>
  50. <tr>
  51. <td valign="top">message</td>
  52. <td valign="top">Message to send in the body of the email.</td>
  53. <td align="center" valign="middle" rowspan="2">One of these or a
  54. <code>&lt;message&gt;</code> element.</td>
  55. </tr>
  56. <tr>
  57. <td valign="top">messagefile</td>
  58. <td valign="top">File to send as the body of the email. Property
  59. values in the file will be expanded.</td>
  60. </tr>
  61. <td valign="top">messagemimetype</td>
  62. <td valign="top">The content type of the message. The default is
  63. <code>text/plain</code>.</td>
  64. <td align="center" valign="top">No</td>
  65. </tr>
  66. <tr>
  67. <td valign="top">files</td>
  68. <td valign="top">Files to send as attachments to the email. Separate multiple
  69. file names using a comma or space. You can also use <code>&lt;fileset&gt;</code>
  70. elements to specify files.</td>
  71. <td align="center" valign="top">No</td>
  72. </tr>
  73. <tr>
  74. <td valign="top">failonerror</td>
  75. <td valign="top">flag to indicate whether to halt the build on
  76. any error. The default value is <code>true</code>.</td>
  77. <td align="center" valign="top">No.</td>
  78. </tr>
  79. <tr>
  80. <td valign="top">includefilenames</td>
  81. <td valign="top">Include filename(s) before file contents.
  82. Valid only when the <code>plain</code> encoding is used. The default
  83. value is <code>false</code>.</td>
  84. <td align="center" valign="top">No</td>
  85. </tr>
  86. <tr>
  87. <td valign="top">mailhost</td>
  88. <td valign="top">Host name of the SMTP server. The default value is
  89. <code>localhost</code>.</td>
  90. <td align="center" valign="top">No</td>
  91. </tr>
  92. <tr>
  93. <td valign="top">mailport</td>
  94. <td valign="top">TCP port of the SMTP server. The default value is 25.</td>
  95. <td align="center" valign="top">No</td>
  96. </tr>
  97. <tr>
  98. <td valign="top">encoding</td>
  99. <td valign="top">Specifies the encoding to use for the content of the email.
  100. Values are <code>mime</code>, <code>uu</code>, <code>plain</code>, or
  101. <code>auto</code>. The default value is <code>auto</code>.</td>
  102. <td align="center" valign="top">No</td>
  103. </tr>
  104. <tr>
  105. <td valign="top">charset</td>
  106. <td valign="top">Character set of the email.<br>
  107. You can also set the charset in the message nested element.<br>
  108. These options are mutually exclusive.</td>
  109. <td align="center" valign="top">No</td>
  110. </tr>
  111. <tr>
  112. <td valign="top">subject</td>
  113. <td valign="top">Email subject line.</td>
  114. <td align="center" valign="top">No</td>
  115. </tr>
  116. </table>
  117. <h3>Parameters specified as nested elements</h3>
  118. <h4>to / cc / bcc / from/ replyto </h4>
  119. <p>Adds an email address element. It takes the following attributes:</p>
  120. <table width="60%" border="1" cellpadding="2" cellspacing="0">
  121. <tr>
  122. <td valign="top"><b>Attribute</b></td>
  123. <td valign="top"><b>Description</b></td>
  124. <td align="center" valign="top"><b>Required</b></td>
  125. </tr>
  126. <tr>
  127. <td valign="top">name</td>
  128. <td valign="top">The display name for the address.</td>
  129. <td align="center" valign="top">No</td>
  130. </tr>
  131. <tr>
  132. <td valign="top">address</td>
  133. <td valign="top">The email address.</td>
  134. <td align="center" valign="top">Yes</td>
  135. </tr>
  136. </table>
  137. <h4>message</h4>
  138. <p>Specifies the message to include in the email body. It takes the following
  139. attributes:</p>
  140. <table width="60%" border="1" cellpadding="2" cellspacing="0">
  141. <tr>
  142. <td valign="top"><b>Attribute</b></td>
  143. <td valign="top"><b>Description</b></td>
  144. <td align="center" valign="top"><b>Required</b></td>
  145. </tr>
  146. <tr>
  147. <td valign="top">src</td>
  148. <td valign="top">The file to use as the message.</td>
  149. <td align="center" valign="top">No</td>
  150. </tr>
  151. <tr>
  152. <td valign="top">mimetype</td>
  153. <td valign="top">The content type to use for the message.</td>
  154. <td align="center" valign="top">No</td>
  155. </tr>
  156. <tr>
  157. <td valign="top">charset</td>
  158. <td valign="top">Character set of the message<br>
  159. You can also set the charset as attribute of the enclosing mail task.<br>
  160. These options are mutually exclusive.</td>
  161. <td align="center" valign="top">No</td>
  162. </tr>
  163. </table>
  164. <p>If the <code>src</code> attribute is not specified, then text can be added
  165. inside the <code>&lt;message&gt;</code> element. Property expansion will occur
  166. in the message, whether it is specified as an external file or as text within
  167. the <code>&lt;message&gt;</code> element.</p>
  168. <h3>Examples</h3>
  169. <blockquote><pre>
  170. &lt;mail from=&quot;me&quot;
  171. tolist=&quot;you&quot;
  172. subject=&quot;Results of nightly build&quot;
  173. files=&quot;build.log&quot;/&gt;
  174. </pre></blockquote>
  175. <p>Sends an email from <i>me</i> to <i>you</i> with a subject of
  176. <i>Results of nightly build</i> and includes the contents of the file
  177. <i>build.log</i> in the body of the message.</p>
  178. <blockquote><pre>
  179. &lt;mail mailhost=&quot;smtp.myisp.com&quot; mailport=&quot;1025&quot; subject=&quot;Test build&quot;&gt;
  180. &lt;from address=&quot;config@myisp.com&quot;/&gt;
  181. &lt;replyto address=&quot;me@myisp.com&quot;/&gt;
  182. &lt;to address=&quot;all@xyz.com&quot;/&gt;
  183. &lt;message&gt;The ${buildname} nightly build has completed&lt;/message&gt;
  184. &lt;fileset dir=&quot;dist&quot;&gt;
  185. &lt;includes name=&quot;**/*.zip&quot;/&gt;
  186. &lt;/fileset&gt;
  187. &lt;/mail&gt;
  188. </pre></blockquote>
  189. <p>Sends an eMail from <i>config@myisp.com</i> to <i>all@xyz.com</i> with a subject of
  190. <i>Test Build</i>. Replies to this email will go to <i>me@myisp.com</i>.
  191. Any zip files from the dist directory are attached.&nbsp; The
  192. task will attempt to use JavaMail and fall back to UU encoding or no encoding in
  193. that order depending on what support classes are available. <code>${buildname}</code>
  194. will be replaced with the <code>buildname</code> property's value.</p>
  195. <blockquote><pre>
  196. &lt;property name=&quot;line2&quot; value=&quot;some_international_message&quot;/&gt;
  197. &lt;echo message=&quot;${line2}&quot;/&gt;
  198. &lt;mail mailhost=&quot;somehost@xyz.com&quot; mailport=&quot;25&quot; subject=&quot;Test build&quot; charset=&quot;utf-8&quot;&gt;
  199. &lt;from address=&quot;me@myist.com&quot;/&gt;
  200. &lt;to address=&quot;all@xyz.com&quot; /&gt;
  201. &lt;message&gt;some international text:${line2}&lt;/message&gt;
  202. &lt;/mail&gt;
  203. </pre></blockquote>
  204. <p>Sends an eMail from <i>me@myisp.com</i> to <i>all@xyz.com</i> with a subject of
  205. <i>Test Build</i>, the message body being coded in UTF-8
  206. <hr>
  207. <p align="center">Copyright &copy; 2000-2003 Apache Software Foundation. All rights
  208. Reserved.</p>
  209. </body>
  210. </html>