No Subject for Message sent from Java Mail application
843834Mar 4 2009 — edited Mar 4 2009I'm working on a web services application running under Axis2. One of the things the service does is send an e-mail using the Java Mail API. The code to create the e-mail works something like this:
Properties props = new Properties();
props.put("mail.smtp.host", "xxx.xxx.xxx.xxx");
Session session = Session.getDefaultInstance(props, null);
Message message = new MimeMessage(session);
message.setText("Testing the e-mail system");
Address toAddress = new InternetAddress("foo@xxx.com", "FOO");
Address fromAddress = new InternetAddress("bar@xxx.com", "BAR");
message.setSubject("A test subject line");
message.setFrom(fromAddress);
message.addRecipient(Message.RecipientType.TO, toAddress);
Transport.send(message);
When I run this code from my development machine, I get an e-mail sent to me which assigns the proper name to the sender "BAR" and also has a proper subject line. When I deploy this code to another box (running Ubuntu), I still get the e-mail, but I don't get the users name, nor do I get a subject line. I used Wireshark to look at the conversation with my SMTP server, and when run locally, I see in the "DATA" portion of the SMTP conversion is see a 'From:' line and a 'Subject:' line in addition to the text of the message. When I run on the Ubuntu box, I only see the text of the message, not the 'From:' or 'Subject:' lines.
As a further test, I wrote a small Java application which just sends the e-mail message using the same code. When I run this from the command line on the Ubuntu box, the message comes through just fine, it has the proper 'From' address as well as the proper subject.
I'm at a loss as to what might be going on. The Axis server is using the mail-1.4.jar file, which is the same jar file that I use on my development machine. I'm also using the same version of Axis. I downloaded the 1.6.2 version of Mail and used that jar in both my standalone and Axis tests and had the same problem (the simple command line version works, the one invoked through Axis doesn't)
What could be preventing the Mail API from writing my From and Subject line in the Data portion of the SMTP conversation?
Any help would be appreciated.
Thanks!