feat(email): add GPG/PGP email encryption and decryption#18
Merged
qasim-nylas merged 1 commit intomainfrom Feb 4, 2026
Merged
Conversation
Add support for encrypting outgoing emails and decrypting received PGP/MIME encrypted messages (RFC 3156). Sending encrypted email: - --encrypt flag encrypts with recipient's public key - --recipient-key to specify key ID (auto-fetches from key servers) - --sign --encrypt combines signing and encryption - Auto-fetches keys from keys.openpgp.org, keyserver.ubuntu.com, etc. Reading encrypted email: - --decrypt flag decrypts PGP/MIME messages - --decrypt --verify for sign+encrypt messages - Shows decryption key ID and signature verification New files: - internal/adapters/gpg/encrypt.go - encryption/decryption methods - internal/adapters/mime/encrypted.go - PGP/MIME message builder - internal/cli/email/read_decrypt.go - decrypt command handling - docs/commands/encryption.md - comprehensive documentation Also refactored MIME builder to use shared interface for common header writing, reducing code duplication.
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
Add full GPG/PGP email encryption support to the Nylas CLI, complementing the existing signing feature. Users can now send encrypted emails that only the intended recipient can read, and decrypt encrypted emails they receive.
Sending Encrypted Email
--encryptflag encrypts email with recipient's public key--recipient-keyto specify key ID (optional - auto-detects from email)--sign --encryptcombines signing and encryption for maximum securityReading Encrypted Email
--decryptflag decrypts PGP/MIME encrypted messages--decrypt --verifyfor messages that are both signed and encryptedUsage Examples
Changes
New Files
internal/adapters/gpg/encrypt.gointernal/adapters/gpg/encrypt_test.gointernal/adapters/mime/encrypted.gointernal/adapters/mime/encrypted_test.gointernal/cli/email/read_decrypt.gointernal/cli/email/read_decrypt_test.godocs/commands/encryption.mdModified Files
internal/cli/email/send.go- Added--encryptand--recipient-keyflagsinternal/cli/email/send_gpg.go- Refactored for sign/encrypt/both modesinternal/cli/email/read.go- Added--decryptflaginternal/adapters/gpg/service.go- Added interface methodsinternal/adapters/gpg/types.go- Added EncryptResult, DecryptResult typesinternal/adapters/mime/builder.go- Refactored with shared interface to reduce duplicationdocs/COMMANDS.md- Updated with encryption commandsdocs/commands/email.md- Added GPG sectiondocs/commands/email-signing.md- Updated cross-referencesTechnical Details
multipart/encryptedwithprotocol="application/pgp-encrypted"--sign --encryptfor proper orderingmessageRequestinterface reduces code duplication in MIME builderTest Plan
make ci-fullpasses