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

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