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 10 kB

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