Skip to content

feat: Add Gmail REST API backend for native CJK search support #643

@metrovoc

Description

@metrovoc

Problem

IMAP SEARCH on Gmail servers cannot handle CJK (Chinese/Japanese/Korean) characters. This is a known limitation of Gmail's IMAP implementation — search queries containing CJK text return empty results. This affects a significant number of users in East Asia.

Proposed Solution

Add a Gmail REST API backend that uses the Gmail API directly instead of going through IMAP. The Gmail API's q parameter natively supports CJK full-text search.

This backend would implement all existing feature traits (folders, envelopes, messages, flags) by mapping them to Gmail API endpoints:

  • Gmail labels → folders
  • users.messages.list with q param → ListEnvelopes (CJK search works natively)
  • users.messages.get(format=RAW)GetMessages (returns standard RFC 2822)
  • users.messages.sendSendMessage
  • users.messages.modify → flag/copy/move operations
  • OAuth2 authentication (reusing existing OAuth2 infrastructure)

Implementation

I have a working implementation across all three repos (core, tui, himalaya):

All changes compile cleanly with cargo check --features gmail. The implementation follows the same patterns as the existing IMAP/Maildir/Notmuch backends.

I'd be happy to open PRs if you're interested in merging this upstream. Would appreciate feedback on the approach before doing so.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions