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