You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by "Benoit Tellier (Jira)" <se...@james.apache.org> on 2022/05/05 02:56:00 UTC

[jira] [Closed] (JAMES-1489) imap can not search for chinsese keyword

     [ https://issues.apache.org/jira/browse/JAMES-1489?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benoit Tellier closed JAMES-1489.
---------------------------------
    Fix Version/s: 3.8.0
       Resolution: Fixed

- Reader index was not properly reset for  multiple subsequent continuations.

 - Charset was not carried over for all the terms of the search.



> 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
>            Priority: Major
>             Fix For: 3.8.0
>
>          Time Spent: 2h 50m
>  Remaining Estimate: 0h
>
> 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 was sent by Atlassian Jira
(v8.20.7#820007)

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