Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing with "BADCHARSET (US-ASCII)" #15

Open
glennzw opened this issue Feb 13, 2020 · 2 comments
Open

Failing with "BADCHARSET (US-ASCII)" #15

glennzw opened this issue Feb 13, 2020 · 2 comments

Comments

@glennzw
Copy link
Contributor

glennzw commented Feb 13, 2020

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//issues/3
@glennzw
Copy link
Contributor Author

glennzw commented Feb 13, 2020

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.

@jprobinson
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants