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 KiB

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