Webhooks do not include the actual HTML or Plain Text body of the email. You
must call the received emails
API to retrieve them. This
design choice supports large payloads in serverless environments that have
limited request body sizes.
Using the forward helper method
The Node.js SDK provides a forward() helper method that simplifies forwarding received emails. This method automatically handles fetching the email content and attachments.
Here’s an example of forwarding an email in a Next.js application:
app/api/events/route.ts
forward method forwards the email in a way that preserves the original email content and attachments exactly as received.
Alternatively, you can forward emails as if they had been forwarded through an email client, with the forwarded message footer. For that, use passthrough: false and provide custom text or HTML content. The original email will be shown after the forwarded message footer:
app/api/events/route.ts
Manual forwarding
If you’re not using Node.js or prefer not to use theforward helper method, you can manually forward received emails using the Send Email API.
The recommended approach is to download the raw email and parse it to properly extract content and attachments (especially for inline images). Then, you can send a new email with the extracted content and attachments using the Send Email API.
app/api/events/route.ts
This example uses the
mailparser
library (npm install mailparser) to parse the raw email. For other
languages/SDKs, you’ll need an equivalent email parsing library capable of
processing emails compliant to RFC
5322.