Skip to main content
When Lettr receives an email on your inbound domain, it automatically parses the raw email into a structured format. This page explains how different parts of the email are extracted and made available in the webhook payload.

Parsed Email Structure

Inbound emails are delivered as relay.relay_delivery webhook events. Each event contains a relay message with parsed email content:
Webhook payloads are delivered as a JSON array of events. A single delivery may contain one or more events.

Sender Information

From Address

The relay message provides two sender fields:
  • msg_from — the envelope sender (SMTP MAIL FROM), always a bare email address
  • friendly_from — the display name and address from the From header
To extract just the email address or display name from friendly_from:

Reply-To Address

The Reply-To address is available in the content.headers array:

Recipients

Recipients

The relay message provides:
  • rcpt_to — the envelope recipient (the address on your inbound domain that received the email)
  • content.to — the To header addresses from the email
  • CC and BCC addresses are available in the content.headers array
BCC recipients are typically not visible in received emails since they’re stripped by the sending server.

Subject Line

The subject is available in the content object, decoded from any MIME encoding:

Handling Missing Subjects

Email Body

Plain Text and HTML

Emails can contain plain text, HTML, or both. These are available in the content object:

Extracting Text from HTML

Handling Quoted Content

Strip quoted replies to get just the new content:

Email Headers

Standard Headers

Headers are available in content.headers as an array of single-key objects:

Custom Headers

Access any header using the helper:

Date and Time

Sent Timestamp

The original send time is in the Date header:

Character Encoding

Lettr automatically handles character encoding conversion:

Multipart Emails

Emails with multiple parts (text + HTML + attachments) are automatically parsed:
The email_rfc822 field contains the complete raw MIME message, which you can parse with a MIME library if you need access to attachments or other parts not extracted into the structured fields.

Raw MIME Parsing

For advanced use cases like extracting inline images, embedded attachments, or handling complex MIME structures, parse the raw email_rfc822 content with a MIME library:

Parsing Examples

Extract Email Signature

Detect Email Client

Parse Structured Data

Handling Edge Cases

Empty Content

Malformed Addresses

Webhooks

Full webhook payload reference

Attachments

Handle file attachments

Reply Tracking

Track conversation threads

Routing

Route emails based on content