go-imap icon indicating copy to clipboard operation
go-imap copied to clipboard

Search through Chinese subject get empty result

Open tianer1211 opened this issue 4 years ago • 1 comments

Hello,

I try to search email(exchange) through the subject. The subject is Chinese, it could not get any search result. I can get correct result from outlook client searching same string. The code as below:

criteria := imap.NewSearchCriteria()
searchString := "测试" 
criteria.Header.Add("Subject", searchString) 
ids, err := c.Search(criteria) // ids is empty

tianer1211 avatar Jan 25 '22 02:01 tianer1211

your mail server does not support searching for non-ascii characters. my mail server doesn't support it either. i guess outlook client is local search, does not interact with the server. I tested gmail and it is supported, this my debug log (c.SetDebug(os.Stdout)) for gmail:

de9m7A SEARCH CHARSET UTF-8 SUBJECT {6}
+ go ahead
测试
* SEARCH 84 1124 1348
de9m7A OK SEARCH completed (Success)

The key is whether the server returns + go ahead

References: https://stackoverflow.com/questions/27502901/imap-search-for-non-ascii-characters

mac-zhou avatar Aug 05 '22 05:08 mac-zhou