1

Last week I have started working with IMAP mailbox manipulations in TomEE 1.7.0 environment (which contains Geronimo JavaMail 1.4_1.8.3 implementation) connecting to MS Exchange 2007 mail server and I have met some strange behaviour. Based on Google search I have found many others facing into the same difficulties.

when the following IMAP command is executed on an IMAP connection:

a28 APPEND FolderName () "29-Jun-2015 15:01:29 +0200" {7166}
+ Ready for additional command text.

the following exception rises:

org.apache.geronimo.javamail.util.CommandFailedException: Error response received on a IMAP continued command:  + Ready for additional command text.
at org.apache.geronimo.javamail.store.imap.connection.IMAPCommand.writeTo(IMAPCommand.java:205) ~[geronimo-javamail_1.4_mail-1.8.4.jar:1.8.4]
at org.apache.geronimo.javamail.store.imap.connection.IMAPConnection.sendCommand(IMAPConnection.java:319) ~[geronimo-javamail_1.4_mail-1.8.4.jar:1.8.4]
at org.apache.geronimo.javamail.store.imap.connection.IMAPConnection.sendSimpleCommand(IMAPConnection.java:287) ~[geronimo-javamail_1.4_mail-1.8.4.jar:1.8.4]
at org.apache.geronimo.javamail.store.imap.connection.IMAPConnection.appendMessage(IMAPConnection.java:1425) ~[geronimo-javamail_1.4_mail-1.8.4.jar:1.8.4]
at org.apache.geronimo.javamail.store.imap.IMAPFolder.appendMessage(IMAPFolder.java:1564) ~[geronimo-javamail_1.4_mail-1.8.4.jar:1.8.4]
at org.apache.geronimo.javamail.store.imap.IMAPFolder.appendMessages(IMAPFolder.java:988) ~[geronimo-javamail_1.4_mail-1.8.4.jar:1.8.4]

The code is quite simple:

@LocalBean
@Stateless
public class ImapMailManager {

    @Resource(name = "mail/myStore")
    private Session storeSession;

    public void addMessageToFolder(MimeMessage message, String targetFolderName) {
      Store store = storeSession.getStore();

      Properties props = storeSession.getProperties();
      connectUsername = props.getProperty("mail.imaps.user");
      connectPassword = props.getProperty("mail.imaps.password");
      store.connect(connectUsername, connectPassword);

      List<MimeMessage> messagesToCopy = new ArrayList<>();
      messagesToCopy.add(message);
      Message[] messages = new Message[messagesToCopy.size()];
      // the exception raises at the following line:
      store.getFolder(targetFolderName).appendMessages(
        messagesToCopy.toArray(messages)
      );
    }
}

I have the following configuration in tomee.xml:

<Resource id="mail/myStore" type="javax.mail.Session">
    mail.store.protocol=imaps
    mail.imaps.host=mailserver.domain.com
    mail.imaps.port=993
    mail.imaps.auth=true
    mail.imaps.user=user@domain.com
    mail.imaps.password=thePassword
    mail.imaps.auth.ntlm.disable=true
    mail.imaps.auth.gssapi.disable=true
    mail.imaps.auth.plain.disable=true
    mail.debug=true
</Resource>

I have found a lot of thing on Google search which gave me some ideas and helped me just a small step forward:

This was the closest one with my authentication problem (because I had also that one):

I have also read this topic http://www.oracle.com/technetwork/java/javamail/faq/index.html#commonmistakes

So I had to look many more search ... I have tried to patch, upgrade geronimo but not helped.

And finally I have found the right answer here at http://tomee-openejb.979440.n4.nabble.com/TomEE-JavaMail-problems-td4672429.html

So my conclusion was not using geronimo javaMail implementation any more but Oracle JavaMail reference implementation instead.

And after that changes everything worked as it should.

Miklos Krivan
  • 1,732
  • 20
  • 14
  • So, it seems that you've solved your own problem and have no question for us? Great! – Bill Shannon Jul 13 '15 at 02:25
  • Yes it was a question 2-3 weeks ago. It took me many hours to explore and solve it but finally I had a chance. That is why I thought perhaps I can help to others as well. What is the suggested way If I find myself in the same situation again in the near future? Should I ask a question separately and answer it separately? Thx for your feedback and sorry if I did something wrong. I just wanted to help and share my solution. – Miklos Krivan Jul 13 '15 at 18:23

0 Answers0