line break in ant mail message body
how can I put a line break into an ant mail task section ? I've tried almost all possible things so far, like :
<property name="break" value="line break : ${line.separator} \\n\\n"/>
<ech开发者_Python百科o message="${break}"/>
<mail mailhost="" mailport="25" subject="INSTALL BASE on WINDOWS " messagemimetype="text/html">
<from name="The automation system" address=""/>
<replyto address=""/>
<to address=""/>
<message>
build ${LATEST} installed successfully on Windows - silent mode.
${break}
${break}
</message>
</mail>
but it does not work.
You are trying to send html mail with messagemimetype="text/html"
. When html is rendered, any run of whitespace is compressed into a single space, so when you view this message it will all appear on a single line. The line breaks will still be there, try viewing the source of the message in your mail reader.
Since you are creating html mail, adding newline is simply a matter of adding the html <br>
element to your message. Note that you will need to escape the <
characters as you are embedding the message in the xml of the build file:
<message>
build ${LATEST} installed successfully on Windows - silent mode.<br>
Another line here<br>
Last line
</message>
Alternately wrap the whole message in a CDATA block:
<message><![CDATA[
build ${LATEST} installed successfully on Windows - silent mode.<br>
Another line here<br>
Last line
]]></message>
Since this is message generated by a build script and therefore I assume the recipient is a developer, you might want to send the message as plain text instead. In my experience most developers prefer plain text emails, and may have the email reader setup not to display html messages at all (or may be reading mail from a client that can't handle html like a command line reader). If you want to do this just delete messagemimetype="text/html"
. Newlines will then appear as expected.
Please remove the mimetype attribute and try to use this :
<message>
Test... Test...
</message>
This should get you going. If you indeed want to use the html attribute then you are better of using passing an html file with the correct encoding. THERE the
element will work.
精彩评论