feat(email): support inline PGP decryption for Outlook emails#19
Merged
qasim-nylas merged 2 commits intonylas:mainfrom Feb 4, 2026
Merged
feat(email): support inline PGP decryption for Outlook emails#19qasim-nylas merged 2 commits intonylas:mainfrom
qasim-nylas merged 2 commits intonylas:mainfrom
Conversation
Some email providers (e.g., Microsoft/Outlook) transform PGP/MIME encrypted messages into multipart/mixed with inline PGP blocks. This adds fallback detection for inline PGP content when the message is not in standard PGP/MIME format. Also improves error propagation in GPG signing/encryption functions to provide meaningful error messages instead of generic failures.
Outlook/Microsoft transforms PGP/MIME emails into multipart/mixed with base64-encoded attachments. The extractInlinePGP function now checks Content-Transfer-Encoding and decodes base64 content before searching for PGP markers. - Add base64 decoding for MIME parts with Content-Transfer-Encoding: base64 - Add test for Outlook-style base64-encoded PGP attachments
qasim-nylas
approved these changes
Feb 4, 2026
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
Some email providers (notably Microsoft/Outlook) transform PGP/MIME encrypted messages when storing them. Instead of preserving the standard
multipart/encrypted; protocol="application/pgp-encrypted"structure, they convert it tomultipart/mixedwith the PGP block as inline text.This PR adds:
-----BEGIN PGP MESSAGE-----blocks when the message is not in standard PGP/MIME formatextractInlinePGPfunction covering various scenariosProblem
When using
nylas email read <id> --decrypton emails received via Microsoft/Outlook, decryption fails with:This happens because Outlook transforms the original PGP/MIME structure:
Original (Gmail preserves this):
After Outlook transformation:
Solution
The
decryptGPGEmailfunction now:Changes
internal/cli/email/read_decrypt.goextractInlinePGP()function, updateddecryptGPGEmail()to use fallbackinternal/cli/email/read_decrypt_test.goextractInlinePGP()internal/cli/email/send_gpg.gobuild*Message()functions to return([]byte, error)for proper error propagationTest plan
go test ./internal/cli/email/...)golangci-lint run)make ci)Compatibility