go-imap
go-imap copied to clipboard
Search through Chinese subject get empty result
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
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