eazye
eazye copied to clipboard
Failing with "BADCHARSET (US-ASCII)"
When trying to retrieve unread emails from Microsoft Exchange servers the following error is encountered:
uid search failed: imap: unexpected completion status ("RXUGA5 NO [BADCHARSET (US-ASCII)] The specified charset is not supported.")
Failure occurs here: https://github.com/jprobinson/eazye/blob/master/eazye.go#L337
Doing some Googling it seems like it's a Microsoft Exchange issue. The BADCHARSET response-code provides a list of supported charsets, not the charset that is invalid. The charset that is invalid is the charset used in the UIDSearch() command (which I assume is UTF-8).
Given that the github.com/mxk/go-imap/imap
project hasn't been updated in over 5 years I'm guessing something 'modern' might be breaking things. Digging into this project I find the following code:
// UIDSearch is identical to Search, but the numbers returned in the response
// are unique identifiers instead of message sequence numbers.
func (c *Client) UIDSearch(spec ...Field) (cmd *Command, err error) {
return c.Send("UID SEARCH", append([]Field{"CHARSET", "UTF-8"}, spec...)...)
}
https://github.com/mxk/go-imap/blob/master/imap/imap.go#L377
The CHARSET here being specified as UTF-8. I changed this is "US-ASCII" and I am able to login to Outlook servers.
EDIT: I see this was raised some years ago https://github.com/jprobinson/eazye/issues/3
I've fixed this problem in my own fork of mxk/go-imap
by removing the hard-coded UTF-8.
https://github.com/glennzw/go-imap
I submitted a pull request but I don't think the project is being maintained.
Thanks for digging into this and sorry for the delay 😅
For now, I imagine you can probably get by with a replace
directive in your go.mod
but that's likely not ideal.
If time goes by and your PR doesn't get merged, we can look to point at your fork via imports or something else.
🤞 things get merged.