james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "roger zhang (JIRA)" <server-...@james.apache.org>
Subject [jira] [Created] (JAMES-1489) imap can not search for chinsese keyword
Date Tue, 19 Mar 2013 03:47:15 GMT
roger zhang created JAMES-1489:
----------------------------------

             Summary: imap can not search for chinsese keyword
                 Key: JAMES-1489
                 URL: https://issues.apache.org/jira/browse/JAMES-1489
             Project: James Server
          Issue Type: Bug
          Components: IMAPServer
    Affects Versions: 3.0-beta4
            Reporter: roger zhang


i want to use javamail search command to search chinese email on the subject,body. but ImapRequestFrameDecoder
class return issue. the simple code below

import javax.mail.Session;
import javax.mail.Store;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.search.*;
import java.util.Properties;

public class ImapSearchMail {

    public static void main(String args[]) throws Exception {
        String host = "127.0.0.1";
        String username = "1@roger.com";
        String password = "1"; // passwd
        Properties props = new Properties();
        props.put("mail.debug", "true");
        Session session = Session.getDefaultInstance(props, null);
        Store store = session.getStore("imap");
        store.connect(host, username, password);
        Folder folder = store.getFolder("INBOX");
        folder.open(Folder.READ_ONLY);

        SearchTerm subjectTerm = new SubjectTerm("java培训");
        SearchTerm fromTerm = new FromStringTerm("采购");
        SearchTerm recipientTerm = new RecipientStringTerm(Message.RecipientType.TO,"张三");
        SearchTerm ccRecipientTerm = new RecipientStringTerm(Message.RecipientType.CC,"李四");
        SearchTerm bccRecipientTerm = new RecipientStringTerm(Message.RecipientType.BCC,"王五");
        SearchTerm bodyTerm = new BodyTerm("天天向上");
 

        SearchTerm[] searchTerms = new SearchTerm[6];
        searchTerms[0] = subjectTerm;
        searchTerms[1] = bodyTerm;
        searchTerms[2] = fromTerm;
        searchTerms[3] = recipientTerm;
        searchTerms[4] = ccRecipientTerm;
        searchTerms[5] = bccRecipientTerm;


        //SearchTerm orTerm = new OrTerm(searchTerms);
        SearchTerm andTerm = new AndTerm(searchTerms);
        Message[] msgs = folder.search(andTerm);
        System.out.println(msgs.length);
        folder.close(false);
        store.close();
    }
}

issue:
A3 EXAMINE INBOX
* FLAGS (\Answered \Deleted \Draft \Flagged \Seen)
* 19 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 971233197] UIDs valid
* OK [UNSEEN 2] Message 2 is first unseen
* OK [PERMANENTFLAGS (\Answered \Deleted \Draft \Flagged \Seen \*)] Limited
* OK [HIGHESTMODSEQ 19] Highest
* OK [UIDNEXT 20] Predicted next UID
A3 OK [READ-ONLY] EXAMINE completed.
A4 SEARCH CHARSET UTF-8 SUBJECT {10+}
java鍩硅 BODY {12+}
澶╁ぉ鍚戜笂 FROM {6+}
閲囪喘 TO {6+}
寮犱笁 CC {6+}
鏉庡洓 BCC {6+}
鐜嬩簲 ALL
* BAD failed. Unknown command.
* BAD failed. Unknown command.
* BAD failed. Unknown command.
* BAD failed. Unknown command.
* BAD failed. Unknown command.
* BAD failed. Unknown command.
Exception in thread "main" javax.mail.FolderClosedException: * BYE JavaMail Exception: java.io.IOException:
Connection dropped by server?
	at com.sun.mail.imap.IMAPFolder.search(IMAPFolder.java:1674)
	at test.dataserver.comm.searchmail.ImapSearchMail.main(ImapSearchMail.java:55)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message