Skip to content

feat(email): auto-detect inbox provider for transactional send#17

Merged
qasim-nylas merged 1 commit intomainfrom
feat/inbox-transactional-send
Feb 3, 2026
Merged

feat(email): auto-detect inbox provider for transactional send#17
qasim-nylas merged 1 commit intomainfrom
feat/inbox-transactional-send

Conversation

@qasim-nylas
Copy link
Collaborator

@qasim-nylas qasim-nylas commented Feb 3, 2026

Summary

Automatically detect when a grant uses the Nylas Inbox provider and route email sends through the domain-based transactional endpoint instead of the grant-based endpoint.

User Experience: No changes required - the CLI automatically selects the correct endpoint based on the grant's provider type.

# Works the same for all providers - CLI auto-detects!
nylas email send --to user@example.com --subject "Hello" --body "Hi"

# For inbox provider grants, automatically uses:
# POST /v3/domains/{domain}/messages/send

# For Google/Microsoft/IMAP grants, uses:
# POST /v3/grants/{grant_id}/messages/send

Changes

  • New port interface: TransactionalClient for domain-based email sending
  • New adapter: SendTransactionalMessage for POST /v3/domains/{domain}/messages/send
  • New helper: ExtractDomain() to parse domain from email addresses (e.g., info@qasim.nylas.emailqasim.nylas.email)
  • Updated send command: Auto-detects provider type and routes to appropriate endpoint
  • Mock/Demo implementations: For testing and demo mode support
  • Comprehensive tests: Unit tests for adapter, helper, and mock

Files Changed

File Description
internal/ports/transactional.go New port interface
internal/ports/nylas.go Embed TransactionalClient
internal/adapters/nylas/transactional.go HTTP client implementation
internal/adapters/nylas/mock_transactional.go Mock for testing
internal/adapters/nylas/demo_transactional.go Demo client support
internal/adapters/nylas/transactional_test.go Unit tests
internal/cli/common/string.go ExtractDomain helper
internal/cli/common/string_test.go Helper tests
internal/cli/email/send.go Auto-detection logic

Test Plan

  • Unit tests pass for ExtractDomain helper
  • Unit tests pass for SendTransactionalMessage adapter
  • Unit tests pass for error handling scenarios
  • Mock client implements interface correctly
  • Full CI pipeline passes (make ci)
  • Manual test with inbox provider grant
  • Manual test with Google/Microsoft grant (no regression)

Automatically detect when a grant uses the Nylas Inbox provider and
route email sends through the domain-based transactional endpoint
instead of the grant-based endpoint.

Changes:
- Add TransactionalClient port interface for domain-based email sending
- Implement SendTransactionalMessage adapter for POST /v3/domains/{domain}/messages/send
- Add ExtractDomain helper to parse domain from email addresses
- Update email send command to auto-detect provider type:
  - Inbox provider: uses POST /v3/domains/{domain}/messages/send
  - Other providers (Google/Microsoft/IMAP): uses POST /v3/grants/{id}/messages/send
- Add mock and demo client implementations
- Add comprehensive unit tests

User experience remains unchanged - the CLI automatically selects
the correct endpoint based on the grant's provider type.
@qasim-nylas qasim-nylas merged commit a1d8863 into main Feb 3, 2026
6 checks passed
@qasim-nylas qasim-nylas deleted the feat/inbox-transactional-send branch February 3, 2026 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant