Bug 51353 - Mail task fails to send correctly on IBM z/OS EBCDIC operating system
Summary: Mail task fails to send correctly on IBM z/OS EBCDIC operating system
Status: NEW
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.7.1
Hardware: Other other
: P2 normal (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-10 14:30 UTC by matthew1001
Modified: 2011-06-10 14:30 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description matthew1001 2011-06-10 14:30:44 UTC
On attempting to use the Ant mail task on an IBM z/OS environment running in the EBCDIC codepage, the mail fails to send completely.

The problem appears to be related to the JVM failing to flush the the output stream correctly when it encounters a /n character in the PrintStream.write(int byte) method on an EBCDIC environment. However, I don't believe this is a JVM bug. 

When the JVM fails to flush the stream, the mail task hangs waiting for the SMTP server to respond, which it never will as the stream hasn't been flushed.

The following build.xml can be used to recreate the problem on an EBCDIC environment:

<?xml version="1.0" ?>
<project>
 <target name="SEND_EMAIL" >
  <mail mailhost="my.mailserver.com"
	mailport="25"
	subject="My email test"
	encoding="plain">
	<from address="matthew1001@hotmail.com"/>
	<to address="matthew1001@hotmail.com"/>
	<message>this is a test message</message>
  </mail>
 </target>
</project>

A similar issue exists in the writing of MIME headers to the SMTP server. 

I believe PrintStream.println(String x) is used to write MIME headers, but the javadoc for PrintStream.println(String x) says that the string's characters are converted into bytes according to the platform's default character encoding. However, if your SMTP server doesn't support EBCDIC it won't understand the MIME headers being sent from an EBCDIC environment. 

I believe the fix for this would be to use the PrintStream.write(byte[] buff, int off, int len) method to write the headers to the output stream instead. The String.getBytes(String charsetName) method should be used to provide the byte buffer in the correct character set.