Parsed Email Structure
Inbound emails are delivered asrelay.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 addressfriendly_from— the display name and address from theFromheader
friendly_from:
Reply-To Address
The Reply-To address is available in thecontent.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— theToheader addresses from the email- CC and BCC addresses are available in the
content.headersarray
BCC recipients are typically not visible in received emails since they’re stripped by the sending server.
Subject Line
The subject is available in thecontent 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 thecontent object:
Extracting Text from HTML
Handling Quoted Content
Strip quoted replies to get just the new content:Email Headers
Standard Headers
Headers are available incontent.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 theDate header:
Character Encoding
Lettr automatically handles character encoding conversion:Multipart Emails
Emails with multiple parts (text + HTML + attachments) are automatically parsed: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 rawemail_rfc822 content with a MIME library:
Parsing Examples
Extract Email Signature
Detect Email Client
Parse Structured Data
Handling Edge Cases
Empty Content
Malformed Addresses
Related Topics
Webhooks
Full webhook payload reference
Attachments
Handle file attachments
Reply Tracking
Track conversation threads
Routing
Route emails based on content