Support UTF8=ACCEPT (RFC 9755)
Gmail advertises the UTF8=ACCEPT server capability defined in RFC 9755:
S: * CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 UIDPLUS COMPRESS=DEFLATE ENABLE MOVE CONDSTORE ESEARCH UTF8=ACCEPT LIST-EXTENDED LIST-STATUS LITERAL- SPECIAL-USE APPENDLIMIT=35651584
Enabling this client capability is simple enough (BTW, all protocol output here is from session.debug = true):
session.run_command_and_check_ok("ENABLE UTF8=ACCEPT")?;
C: a3 ENABLE UTF8=ACCEPT
S: * ENABLED UTF8=ACCEPT
S: a3 OK Success
After enabling the client capability, server responses now contain pure, sweet UTF-8 without any further batshit crazy legacy encoding:
# Without UTF8=ACCEPT
S: * 13 FETCH (UID 222 ENVELOPE ("Fri, 13 Jun 2025 16:40:17 +0000" "=?UTF-8?Q?=F0=9F=99=8C_Complete_your_sign_up_to_ASIMOV.Blog!?=" (("ASIMOV.Blog" NIL "asimov-blog" "ghost.io")) ((NIL NIL "asimov-blog" "ghost.io")) ((NIL NIL "noreply" "asimov-blog.ghost.io")) ((NIL NIL "arto" "asimov.systems")) NIL NIL NIL "<[email protected]>"))
# With UTF8=ACCEPT
S: * 13 FETCH (UID 222 ENVELOPE ("Fri, 13 Jun 2025 16:40:17 +0000" "🙌 Complete your sign up to ASIMOV.Blog!" (("ASIMOV.Blog" NIL "asimov-blog" "ghost.io")) ((NIL NIL "asimov-blog" "ghost.io")) ((NIL NIL "noreply" "asimov-blog.ghost.io")) ((NIL NIL "arto" "asimov.systems")) NIL NIL NIL "<[email protected]>"))
However, something in this crate is not quite ready for this straightforward UTF-8 world, and the connection gets closed after receiving the first ENVELOPE with UTF-8 data (#71?):
S: * 13 FETCH (UID 222 ENVELOPE ("Fri, 13 Jun 2025 16:40:17 +0000" "🙌 Complete your sign up to ASIMOV.Blog!" (("ASIMOV.Blog" NIL "asimov-blog" "ghost.io")) ((NIL NIL "asimov-blog" "ghost.io")) ((NIL NIL "noreply" "asimov-blog.ghost.io")) ((NIL NIL "arto" "asimov.systems")) NIL NIL NIL "<[email protected]>"))
Error: Bye(Bye { information: "no explanation given", code: None })
Oh, yeah, this would be a great thing to add, I agree!
Unfortunately, I don't really have capacity to maintain this crate the way it needs to be any more. I've tried to find other maintainers, but all of them have fallen through so far. Would you be interested perhaps? I'd be happy to help review some things in the handover period!
@jonhoo I could certainly take a stab at co-maintainership with you, at least! This crate is mission critical for us, so it would make sense.
That'd be amazing! In general, there are (as you can see) quite a few issues / PRs that could use some love. Overall though, I suspect the crate is due for a bit of a rewrite, possibly to make it async. Originally, @soywod volunteered to step up into the maintainer role here in https://github.com/jonhoo/rust-imap/issues/302, though that didn't end up manifesting. Perhaps you could chime in on that thread?