Skip to content

feat: add method to help with forwarding inbound emails#797

Merged
gabrielmfern merged 2 commits intocanaryfrom
feat/forwarding-method
Jan 26, 2026
Merged

feat: add method to help with forwarding inbound emails#797
gabrielmfern merged 2 commits intocanaryfrom
feat/forwarding-method

Conversation

@lucasfcosta
Copy link
Contributor

@lucasfcosta lucasfcosta commented Jan 19, 2026

This PR adds a helper method for forwarding inbound emails that works as shown below.

IMO the most important thing to notice here is that we need to make a call of whether we want to add mailparser as a dependency because that's necessary for the passthrough forwarding to work.

The rest of the code is mostly simple.

// Passthrough (default) - content sent directly, doesn't look like it was forwarded
await resend.emails.receiving.forward({
  emailId: payload.data.email_id,
  to: payload.data.from,
  from: 'passthrough@example.com',
});

// Wrapped - content wrapped in a `forwarded` part
await resend.emails.receiving.forward({
  emailId: payload.data.email_id,
  to: payload.data.from,
  from: 'wrapped@example.com',
  passthrough: false,
  text: 'See the attached email.',
});

This is an SDK-only change.


Summary by cubic

Adds resend.emails.receiving.forward to forward inbound emails, either as-is (passthrough) or as a wrapped forward with the original message attached. Preserves subject, body, and attachments to support simple routing flows.

  • New Features

    • New forwarding method:
      • Passthrough (default): sends parsed original text/html and attachments without a “forwarded” look.
      • Wrapped: prefixes subject with “Fwd:” and attaches the original .eml; requires text or html.
    • Receiving email response now includes raw.download_url and raw.expires_at; list response omits raw.
    • Preserves inline attachments (content_id with brackets stripped), sets “(no subject)” when missing, and returns clear errors for missing/undownloadable raw content.
  • Dependencies

    • Added mailparser@3.7.2 and @types/mailparser for parsing raw messages in passthrough mode.

Written for commit 18d57b1. Summary will update on new commits.

@lucasfcosta lucasfcosta requested a review from a team as a code owner January 19, 2026 15:43
@socket-security
Copy link

socket-security bot commented Jan 19, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​types/​mailparser@​3.4.51001007381100
Addedmailparser@​3.7.2991008086100

View full report

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 19, 2026

Open in StackBlitz

npm i https://pkg.pr.new/resend/resend-node/resend@797

commit: 18d57b1

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 8 files

@gabrielmfern gabrielmfern merged commit 0d97792 into canary Jan 26, 2026
11 of 12 checks passed
@gabrielmfern gabrielmfern deleted the feat/forwarding-method branch January 26, 2026 16:50
@Shubhdeep12 Shubhdeep12 mentioned this pull request Feb 6, 2026
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.

2 participants