Add exportmessages action to IMAP, POP3, and MS Graph protocols#80
Merged
Conversation
Extracts createExportDir/sanitizeFilename into internal/common/export (used by exportinbox, searchandexport, and the new exportmessages command), and adds msgraph exportmessages to search by --messageid and/or --subject and export matches as raw .eml files. All export commands gain a --exportdir flag to override the default %TEMP%/export/<date>/ location.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a new
exportmessagesaction across three email protocols (IMAP, POP3, and MS Graph) that allows users to search for messages by Internet Message-ID and/or subject substring, then export matching messages as raw RFC822.emlfiles.Key Changes
New Features
exportmessagescommand that uses SEARCH to find messages by Message-ID/Subject headers and exports them via FETCHexportmessagescommand that uses TOP to fetch headers for matching criteria and RETR to export full messagesexportmessagescommand that uses OData filters to search by internetMessageId and subject, then downloads raw MIME contentShared Infrastructure
internal/common/exportpackage with:CreateExportDir(): Generates dated export directories (<baseDir>/export/YYYY-MM-DD/)SanitizeFilename(): Sanitizes filenames for filesystem safetycreateExportDir()andsanitizeFilename()functions to use the shared packageProtocol-Specific Implementations
IMAP (
internal/protocols/imap/):SelectMailbox(),SearchMessages(), andFetchRFC822()client methodsexportmessages.gowith search/export logic and CSV loggingmessageid,subject,mailbox,count, andexportdirparametersPOP3 (
internal/protocols/pop3/):Top()andRetr()client methods for header/body retrievalexportmessages.gowith header matching and export logicmessageid,subject,count, andexportdirparametersMS Graph (
internal/protocols/msgraph/):exportMessages()andexportMessageToEML()handlersNewEmailGetRequest(),ParseEmailGetResponse(), andBuildEmailSearchFilter()exportdirparametervalidateSearchSubject()utility for OData filter validationDocumentation
docs/protocols/imap.md,docs/protocols/pop3.md, anddocs/protocols/msgraph.mdwith usage examples and flag documentation for the newexportmessagesactionImplementation Details
.emlfiles with sanitized filenames based on Message-ID or message number/UIDhttps://claude.ai/code/session_01XqmZvaRnk6rQ2whp5DaBb5