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 12 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <!--
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. -->
  15. <html>
  16. <head>
  17. <meta http-equiv="Content-Language" content="en-us">
  18. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  19. <title>Mail Task</title>
  20. </head>
  21. <body>
  22. <h2><a name="mail">Mail</a></h2>
  23. <h3>Description</h3>
  24. <p>
  25. A task to send SMTP email.
  26. </p>
  27. <p>
  28. This task can send mail using either plain
  29. text, UU encoding, or MIME format mail, depending on what is available.
  30. </p>
  31. <p>
  32. SMTP auth and SSL/TLS require JavaMail and are only available in MIME format.
  33. </p>
  34. <p>
  35. Attachments may be sent using nested
  36. <code>&lt;attachments&gt;</code> elements, which are <a
  37. href="../using.html#path">path-like structures</a>. This means
  38. any filesystem based <a
  39. href="../CoreTypes/resources.html">resource</a> or resource
  40. collection can be used to point to attachments. Prior to Ant 1.7
  41. only <code>&lt;fileset&gt;</code> has been supported as a nested
  42. element, you can still use this directly without an
  43. <code>&lt;attachments&gt;</code> container.
  44. </p>
  45. <p>
  46. <strong>Note:</strong> This task may depend on external libraries
  47. that are not included in the Ant distribution.
  48. See <a href="../install.html#librarydependencies">Library Dependencies</a>
  49. for more information.
  50. </p>
  51. <h3>Parameters</h3>
  52. <table border="1" cellpadding="2" cellspacing="0">
  53. <tr>
  54. <td valign="top"><b>Attribute</b></td>
  55. <td valign="top"><b>Description</b></td>
  56. <td align="center" valign="top"><b>Required</b></td>
  57. </tr>
  58. <tr>
  59. <td valign="top">from</td>
  60. <td valign="top">Email address of sender.</td>
  61. <td align="center" valign="top">Either a <code>from</code> attribute, or a <code>&lt;from&gt;</code>
  62. element.</td>
  63. </tr>
  64. <tr>
  65. <td valign="top">replyto</td>
  66. <td valign="top">Replyto email address.</td>
  67. <td align="center" valign="top">No</td>
  68. </tr>
  69. <tr>
  70. <td valign="top">tolist</td>
  71. <td valign="top">Comma-separated list of recipients.</td>
  72. <td align="center" valign="middle" rowspan="3">At least one of these, or the
  73. equivalent elements.</td>
  74. </tr>
  75. <tr>
  76. <td valign="top">cclist</td>
  77. <td valign="top">Comma-separated list of recipients to carbon copy</td>
  78. </tr>
  79. <tr>
  80. <td valign="top">bcclist</td>
  81. <td valign="top">Comma-separated list of recipients to blind carbon copy
  82. </td>
  83. </tr>
  84. <tr>
  85. <td valign="top">message</td>
  86. <td valign="top">Message to send in the body of the email.</td>
  87. <td align="center" valign="middle" rowspan="2">One of these or a
  88. <code>&lt;message&gt;</code> element.</td>
  89. </tr>
  90. <tr>
  91. <td valign="top">messagefile</td>
  92. <td valign="top">File to send as the body of the email. Property
  93. values in the file will be expanded.</td>
  94. </tr>
  95. <td valign="top">messagemimetype</td>
  96. <td valign="top">The content type of the message. The default is
  97. <code>text/plain</code>.</td>
  98. <td align="center" valign="top">No</td>
  99. </tr>
  100. <tr>
  101. <td valign="top">files</td>
  102. <td valign="top">Files to send as attachments to the email. Separate multiple
  103. file names using a comma or space. You can also use <code>&lt;fileset&gt;</code>
  104. elements to specify files.</td>
  105. <td align="center" valign="top">No</td>
  106. </tr>
  107. <tr>
  108. <td valign="top">failonerror</td>
  109. <td valign="top">flag to indicate whether to halt the build on
  110. any error. The default value is <code>true</code>.</td>
  111. <td align="center" valign="top">No.</td>
  112. </tr>
  113. <tr>
  114. <td valign="top">includefilenames</td>
  115. <td valign="top">Include filename(s) before file contents.
  116. Valid only when the <code>plain</code> encoding is used. The default
  117. value is <code>false</code>.</td>
  118. <td align="center" valign="top">No</td>
  119. </tr>
  120. <tr>
  121. <td valign="top">mailhost</td>
  122. <td valign="top">Host name of the SMTP server. The default value is
  123. <code>localhost</code>.</td>
  124. <td align="center" valign="top">No</td>
  125. </tr>
  126. <tr>
  127. <td valign="top">mailport</td>
  128. <td valign="top">TCP port of the SMTP server. The default value is 25.</td>
  129. <td align="center" valign="top">No</td>
  130. </tr>
  131. <tr>
  132. <td valign="top">user</td>
  133. <td valign="top">user name for SMTP auth</td>
  134. <td valign="center">Yes, if SMTP auth is required on your SMTP server<br></br>
  135. the email message will be then sent using Mime and requires JavaMail</td>
  136. </tr>
  137. <tr>
  138. <td valign="top">password</td>
  139. <td valign="top">password for SMTP auth</td>
  140. <td valign="center">Yes, if SMTP auth is required on your SMTP server<br></br>
  141. the email message will be then sent using Mime and requires JavaMail</td>
  142. </tr>
  143. <tr>
  144. <td valign="top">ssl</td>
  145. <td valign="top">"true", "on" or "yes" accepted here<br></br>
  146. indicates whether you need TLS/SSL</td>
  147. <td valign="center">No</td>
  148. </tr>
  149. <tr>
  150. <td valign="top">encoding</td>
  151. <td valign="top">Specifies the encoding to use for the content of the email.
  152. Values are <code>mime</code>, <code>uu</code>, <code>plain</code>, or
  153. <code>auto</code>. The default value is <code>auto</code>.
  154. <code>uu</code> or <code>plain</code> are not compatible with SMTP auth</td>
  155. <td align="center" valign="top">No</td>
  156. </tr>
  157. <tr>
  158. <td valign="top">charset</td>
  159. <td valign="top">Character set of the email.<br>
  160. You can also set the charset in the message nested element.<br>
  161. These options are mutually exclusive.</td>
  162. <td align="center" valign="top">No</td>
  163. </tr>
  164. <tr>
  165. <td valign="top">subject</td>
  166. <td valign="top">Email subject line.</td>
  167. <td align="center" valign="top">No</td>
  168. </tr>
  169. <tr>
  170. <td valign="top">ignoreInvalidRecipients</td>
  171. <td valign="top">Boolean. Whether the task should try to send
  172. the message to as many recipients as possible and should only
  173. fail if neither is reachable. <em>Since Ant 1.8.0</em>.</td>
  174. <td align="center" valign="top">No, default is false</td>
  175. </tr>
  176. <tr>
  177. <td valign="top">enableStartTLS</td>
  178. <td valign="top">"true", "on" or "yes" accepted here<br></br>
  179. whether the STARTTLS command used to switch to an encrypted
  180. connection for authentication should be supported. Requires
  181. JavaMail. <em>Since Ant 1.8.0</em></td>
  182. <td valign="center">No</td>
  183. </tr>
  184. </table>
  185. <h3>Note regarding the attributes containing email addresses</h3>
  186. Since Ant 1.6, the attributes from, replyto, tolist, cclist, bcclist
  187. can contain email addresses of the form :
  188. <ul>
  189. <li>address@xyz.com</li>
  190. <li>name &lt;address@xyz.com&gt;</li>
  191. <li>&lt;address@xyz.com&gt; name</li>
  192. <li>(name) address@xyz.com</li>
  193. <li>address@xyz.com (name)</li>
  194. </ul>
  195. <p>You need to enter the angle brackets as XML entities
  196. <code>&amp;gt;</code> and <code>&amp;lt;</code>.</p>
  197. <h3>Parameters specified as nested elements</h3>
  198. <h4>to / cc / bcc / from/ replyto </h4>
  199. <p>Adds an email address element. It takes the following attributes:</p>
  200. <table width="60%" border="1" cellpadding="2" cellspacing="0">
  201. <tr>
  202. <td valign="top"><b>Attribute</b></td>
  203. <td valign="top"><b>Description</b></td>
  204. <td align="center" valign="top"><b>Required</b></td>
  205. </tr>
  206. <tr>
  207. <td valign="top">name</td>
  208. <td valign="top">The display name for the address.</td>
  209. <td align="center" valign="top">No</td>
  210. </tr>
  211. <tr>
  212. <td valign="top">address</td>
  213. <td valign="top">The email address.</td>
  214. <td align="center" valign="top">Yes</td>
  215. </tr>
  216. </table>
  217. <h4>message</h4>
  218. <p>Specifies the message to include in the email body. It takes the following
  219. attributes:</p>
  220. <table width="60%" border="1" cellpadding="2" cellspacing="0">
  221. <tr>
  222. <td valign="top"><b>Attribute</b></td>
  223. <td valign="top"><b>Description</b></td>
  224. <td align="center" valign="top"><b>Required</b></td>
  225. </tr>
  226. <tr>
  227. <td valign="top">src</td>
  228. <td valign="top">The file to use as the message.</td>
  229. <td align="center" valign="top">No</td>
  230. </tr>
  231. <tr>
  232. <td valign="top">mimetype</td>
  233. <td valign="top">The content type to use for the message.</td>
  234. <td align="center" valign="top">No</td>
  235. </tr>
  236. <tr>
  237. <td valign="top">charset</td>
  238. <td valign="top">Character set of the message<br>
  239. You can also set the charset as attribute of the enclosing mail task.<br>
  240. These options are mutually exclusive.</td>
  241. <td align="center" valign="top">No</td>
  242. </tr>
  243. </table>
  244. <p>If the <code>src</code> attribute is not specified, then text can be added
  245. inside the <code>&lt;message&gt;</code> element. Property expansion will occur
  246. in the message, whether it is specified as an external file or as text within
  247. the <code>&lt;message&gt;</code> element.</p>
  248. <h4>header</h4>
  249. <p><strong>Since Ant 1.7</strong>, arbitrary mail headers can be added by
  250. specifying these attributes on one or more nested header elements:</p>
  251. <table width="60%" border="1" cellpadding="2" cellspacing="0">
  252. <tr>
  253. <td valign="top"><b>Attribute</b></td>
  254. <td valign="top"><b>Description</b></td>
  255. <td align="center" valign="top"><b>Required</b></td>
  256. </tr>
  257. <tr>
  258. <td valign="top">name</td>
  259. <td valign="top">The name associated with this mail header.</td>
  260. <td align="center" valign="top">Yes</td>
  261. </tr>
  262. <tr>
  263. <td valign="top">value</td>
  264. <td valign="top">The value to assign to this mail header.</td>
  265. <td align="center" valign="top">Yes</td>
  266. </tr>
  267. </table>
  268. <p>It is permissible to duplicate the name attribute amongst multiple headers.
  269. </p>
  270. <h3>Examples</h3>
  271. <blockquote><pre>
  272. &lt;mail from=&quot;me&quot;
  273. tolist=&quot;you&quot;
  274. subject=&quot;Results of nightly build&quot;
  275. files=&quot;build.log&quot;/&gt;
  276. </pre></blockquote>
  277. <p>Sends an email from <i>me</i> to <i>you</i> with a subject of
  278. <i>Results of nightly build</i> and includes the contents of the file
  279. <i>build.log</i> in the body of the message.</p>
  280. <blockquote><pre>
  281. &lt;mail mailhost=&quot;smtp.myisp.com&quot; mailport=&quot;1025&quot; subject=&quot;Test build&quot;&gt;
  282. &lt;from address=&quot;config@myisp.com&quot;/&gt;
  283. &lt;replyto address=&quot;me@myisp.com&quot;/&gt;
  284. &lt;to address=&quot;all@xyz.com&quot;/&gt;
  285. &lt;message&gt;The ${buildname} nightly build has completed&lt;/message&gt;
  286. &lt;attachments&gt;
  287. &lt;fileset dir=&quot;dist&quot;&gt;
  288. &lt;include name=&quot;**/*.zip&quot;/&gt;
  289. &lt;/fileset&gt;
  290. &lt;/attachments&gt;
  291. &lt;/mail&gt;
  292. </pre></blockquote>
  293. <p>Sends an eMail from <i>config@myisp.com</i> to <i>all@xyz.com</i> with a subject of
  294. <i>Test Build</i>. Replies to this email will go to <i>me@myisp.com</i>.
  295. Any zip files from the dist directory are attached.&nbsp; The
  296. task will attempt to use JavaMail and fall back to UU encoding or no encoding in
  297. that order depending on what support classes are available. <code>${buildname}</code>
  298. will be replaced with the <code>buildname</code> property's value.</p>
  299. <blockquote><pre>
  300. &lt;property name=&quot;line2&quot; value=&quot;some_international_message&quot;/&gt;
  301. &lt;echo message=&quot;${line2}&quot;/&gt;
  302. &lt;mail mailhost=&quot;somehost@xyz.com&quot; mailport=&quot;25&quot; subject=&quot;Test build&quot; charset=&quot;utf-8&quot;&gt;
  303. &lt;from address=&quot;me@myist.com&quot;/&gt;
  304. &lt;to address=&quot;all@xyz.com&quot;/&gt;
  305. &lt;message&gt;some international text:${line2}&lt;/message&gt;
  306. &lt;/mail&gt;
  307. </pre></blockquote>
  308. <p>Sends an eMail from <i>me@myisp.com</i> to <i>all@xyz.com</i> with a subject of
  309. <i>Test Build</i>, the message body being coded in UTF-8
  310. </body>
  311. </html>