Skip to content

Add Inbound Email API support - #66

Open
mklocek wants to merge 5 commits into
mainfrom
inbound-v2
Open

Add Inbound Email API support#66
mklocek wants to merge 5 commits into
mainfrom
inbound-v2

Conversation

@mklocek

@mklocek mklocek commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds Inbound Email API support to the Java SDK, matching the released Node, Ruby, MCP, PHP, and Python SDKs. Exposed as client.inboundApi() (token-scoped — no accountId required, mirroring generalApi()).

  • Foldersclient.inboundApi().folders(): getList / getById / create / update / delete
  • Inboxesclient.inboundApi().inboxes(): folder-scoped CRUD (create takes optional domainId)
  • Messagesclient.inboundApi().messages(): list (cursor via lastId) / get / delete + reply / replyAll / forward (send real email)
  • Threadsclient.inboundApi().threads(): list / get / delete

Also carries the other fields that ship with the Inbound Email API:

  • EmailLogMessage / EmailLogMessageSummary: rfcMessageId, inReplyTo, references, threadId
  • SendingDomainsResponse: inboundEnabled, inboundVerified
  • Webhooks: inboundInboxId on Webhook (response) and WebhookInput (create/update request), plus a new WebhookType.INBOUND_RECEIVING — optional, for inbound_receiving webhooks

Notes

  • Endpoints are token-scoped under /api/inbound/...; path ids (folder/inbox/message/thread) are method parameters, and the *Impl classes set apiHost = Constants.GENERAL_HOST.
  • Request bodies are sent flat (the v2 inbound API does not wrap params under a resource key).
  • reply / replyAll / forward reuse Address and EmailAttachment; InboundForwardRequest requires at least one to recipient (validated via @NotEmpty).
  • Thread-message enum fields follow the repo convention: visibilityStatusInboundMessageVisibilityStatus, directionInboundMessageDirection, and deliveryStatus reuses the email-log MessageStatus (same backend delivery_status field).
  • WebhookType.INBOUND_RECEIVING was previously missing; without it the SDK could not create inbound webhooks and would throw when deserializing one.

Summary by CodeRabbit

  • New Features

    • Added Inbound Email API support for managing folders and inboxes.
    • Added capabilities to list, retrieve, delete, reply to, reply-all, and forward inbound messages.
    • Added inbound thread listing, retrieval, pagination, and deletion.
    • Added inbound webhook configuration and sending-domain status fields.
    • Added email threading metadata, attachments, message bodies, and delivery details.
  • Documentation

    • Added Inbound Email API usage guidance and Java examples for folders, inboxes, messages, and threads.

mklocek added 5 commits July 31, 2026 15:38
Jackson/Lombok request and response models for the Inbound Email API:
folders, inboxes, messages (list/details + attachments), threads
(summary/detail/messages), send result, and create/update/reply/forward
request bodies. Reply and forward reuse Address and EmailAttachment from
the send models.
Token-scoped InboundFolders/Inboxes/Messages/Threads interfaces and
impls under /api/inbound (path ids as method params, last_id
pagination, forward validated for at least one recipient), grouped by
MailtrapInboundApi and exposed via client.inboundApi().
Add inbound threading fields (rfc_message_id, in_reply_to, references,
thread_id) to email-log messages, inbound flags (inbound_enabled,
inbound_verified) to sending domains, and the optional inbound_inbox_id
to webhook request and response models. Add the inbound_receiving
webhook type so inbound webhooks can be created and deserialized.
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Added a public Inbound Email API for folders, inboxes, messages, and threads. Added request and response models, client integration, webhook and email-log fields, tests, fixtures, and Java examples.

Changes

Inbound Email API

Layer / File(s) Summary
Inbound contracts and data models
src/main/java/io/mailtrap/api/inbound/*, src/main/java/io/mailtrap/model/request/inbound/*, src/main/java/io/mailtrap/model/response/inbound/*
Added inbound API interfaces, request models, response models, pagination types, message enums, and email-threading fields.
HTTP resources and client wiring
src/main/java/io/mailtrap/api/inbound/*Impl.java, src/main/java/io/mailtrap/client/*, src/main/java/io/mailtrap/factory/*
Added HTTP operations for folders, inboxes, messages, and threads. Exposed them through MailtrapClient.getInboundApi().
API validation and integration tests
src/test/java/io/mailtrap/api/inbound/*, src/test/resources/api/inbound/*, src/test/java/io/mailtrap/api/{emaillogs,sendingdomains,webhooks}/*
Added mock API tests and fixtures for CRUD, pagination, replies, forwarding, deletion, validation, inbound webhooks, and email threading.
Examples and README links
examples/java/io/mailtrap/examples/inbound/*, README.md
Added Java examples for inbound folders, inboxes, messages, and threads. Added README links to the examples.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant MailtrapClient
  participant InboundApi
  participant InboundMessages
  participant MailtrapAPI
  MailtrapClient->>InboundApi: getInboundApi()
  InboundApi->>InboundMessages: access messages resource
  InboundMessages->>MailtrapAPI: list, reply, forward, or delete message
  MailtrapAPI-->>InboundMessages: return typed response
  InboundMessages-->>MailtrapClient: return result
Loading

Possibly related PRs

Suggested reviewers: igordobryn

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 23.26% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main change: adding Inbound Email API support.
Description check ✅ Passed The description clearly explains the API scope and implementation details, but it omits the template's motivation, test checklist, and images sections.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/java/io/mailtrap/api/inbound/InboundMessagesImpl.java`:
- Around line 55-73: Update InboundReplyRequest validation to require at least
one of text or html, then invoke validateRequestBodyAndThrowException(request)
at the start of both InboundMessagesImpl.reply and replyAll before posting.
Preserve the existing request and response handling.

In `@src/main/java/io/mailtrap/model/request/inbound/InboundForwardRequest.java`:
- Around line 31-33: Update the to field in InboundForwardRequest to annotate
its list elements with `@NotNull` and `@Valid`, ensuring every recipient Address is
non-null while preserving the existing non-empty list validation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8465a827-3f9a-4acf-b66c-6ae6b8d8dcd0

📥 Commits

Reviewing files that changed from the base of the PR and between b8df273 and c42b979.

📒 Files selected for processing (71)
  • README.md
  • examples/java/io/mailtrap/examples/inbound/InboundFoldersExample.java
  • examples/java/io/mailtrap/examples/inbound/InboundInboxesExample.java
  • examples/java/io/mailtrap/examples/inbound/InboundMessagesExample.java
  • examples/java/io/mailtrap/examples/inbound/InboundThreadsExample.java
  • src/main/java/io/mailtrap/api/inbound/InboundFolders.java
  • src/main/java/io/mailtrap/api/inbound/InboundFoldersImpl.java
  • src/main/java/io/mailtrap/api/inbound/InboundInboxes.java
  • src/main/java/io/mailtrap/api/inbound/InboundInboxesImpl.java
  • src/main/java/io/mailtrap/api/inbound/InboundMessages.java
  • src/main/java/io/mailtrap/api/inbound/InboundMessagesImpl.java
  • src/main/java/io/mailtrap/api/inbound/InboundThreads.java
  • src/main/java/io/mailtrap/api/inbound/InboundThreadsImpl.java
  • src/main/java/io/mailtrap/client/MailtrapClient.java
  • src/main/java/io/mailtrap/client/api/MailtrapInboundApi.java
  • src/main/java/io/mailtrap/factory/MailtrapClientFactory.java
  • src/main/java/io/mailtrap/model/WebhookType.java
  • src/main/java/io/mailtrap/model/request/inbound/CreateInboundFolderRequest.java
  • src/main/java/io/mailtrap/model/request/inbound/CreateInboundInboxRequest.java
  • src/main/java/io/mailtrap/model/request/inbound/InboundForwardRequest.java
  • src/main/java/io/mailtrap/model/request/inbound/InboundReplyRequest.java
  • src/main/java/io/mailtrap/model/request/inbound/UpdateInboundFolderRequest.java
  • src/main/java/io/mailtrap/model/request/inbound/UpdateInboundInboxRequest.java
  • src/main/java/io/mailtrap/model/request/webhooks/WebhookInput.java
  • src/main/java/io/mailtrap/model/response/emaillogs/EmailLogMessage.java
  • src/main/java/io/mailtrap/model/response/emaillogs/EmailLogMessageSummary.java
  • src/main/java/io/mailtrap/model/response/inbound/InboundAttachment.java
  • src/main/java/io/mailtrap/model/response/inbound/InboundFolder.java
  • src/main/java/io/mailtrap/model/response/inbound/InboundInbox.java
  • src/main/java/io/mailtrap/model/response/inbound/InboundMessage.java
  • src/main/java/io/mailtrap/model/response/inbound/InboundMessageDirection.java
  • src/main/java/io/mailtrap/model/response/inbound/InboundMessageVisibilityStatus.java
  • src/main/java/io/mailtrap/model/response/inbound/InboundMessagesListResponse.java
  • src/main/java/io/mailtrap/model/response/inbound/InboundSendResult.java
  • src/main/java/io/mailtrap/model/response/inbound/InboundThread.java
  • src/main/java/io/mailtrap/model/response/inbound/InboundThreadMessage.java
  • src/main/java/io/mailtrap/model/response/inbound/InboundThreadsListResponse.java
  • src/main/java/io/mailtrap/model/response/sendingdomains/SendingDomainsResponse.java
  • src/main/java/io/mailtrap/model/response/webhooks/Webhook.java
  • src/test/java/io/mailtrap/api/emaillogs/EmailLogsImplTest.java
  • src/test/java/io/mailtrap/api/inbound/InboundFoldersImplTest.java
  • src/test/java/io/mailtrap/api/inbound/InboundInboxesImplTest.java
  • src/test/java/io/mailtrap/api/inbound/InboundMessagesImplTest.java
  • src/test/java/io/mailtrap/api/inbound/InboundThreadsImplTest.java
  • src/test/java/io/mailtrap/api/sendingdomains/SendingDomainsImplTest.java
  • src/test/java/io/mailtrap/api/webhooks/WebhooksImplTest.java
  • src/test/resources/api/emaillogs/getEmailLogMessageResponse.json
  • src/test/resources/api/emaillogs/listEmailLogsResponse.json
  • src/test/resources/api/inbound/createInboundFolderRequest.json
  • src/test/resources/api/inbound/createInboundFolderResponse.json
  • src/test/resources/api/inbound/createInboundInboxRequest.json
  • src/test/resources/api/inbound/createInboundInboxResponse.json
  • src/test/resources/api/inbound/forwardInboundMessageRequest.json
  • src/test/resources/api/inbound/getInboundFolderResponse.json
  • src/test/resources/api/inbound/getInboundInboxResponse.json
  • src/test/resources/api/inbound/getInboundMessageResponse.json
  • src/test/resources/api/inbound/getInboundThreadResponse.json
  • src/test/resources/api/inbound/listInboundFoldersResponse.json
  • src/test/resources/api/inbound/listInboundInboxesResponse.json
  • src/test/resources/api/inbound/listInboundMessagesResponse.json
  • src/test/resources/api/inbound/listInboundThreadsResponse.json
  • src/test/resources/api/inbound/replyAllInboundMessageRequest.json
  • src/test/resources/api/inbound/replyInboundMessageRequest.json
  • src/test/resources/api/inbound/sendInboundMessageResponse.json
  • src/test/resources/api/inbound/updateInboundFolderRequest.json
  • src/test/resources/api/inbound/updateInboundFolderResponse.json
  • src/test/resources/api/inbound/updateInboundInboxRequest.json
  • src/test/resources/api/inbound/updateInboundInboxResponse.json
  • src/test/resources/api/sending_domains/sendingDomainResponse.json
  • src/test/resources/api/webhooks/createInboundWebhookRequest.json
  • src/test/resources/api/webhooks/createInboundWebhookResponse.json

Comment thread src/main/java/io/mailtrap/api/inbound/InboundMessagesImpl.java
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