Overview
Fetch the raw RFC822 message source as base64-encoded bytes. Returns the complete message as it exists on the IMAP server, including all headers, body parts, and attachments. Useful for diagnostics, archival, message export, or tools requiring the complete message structure.Input Parameters
Account identifier. Must match pattern
^[A-Za-z0-9_-]{1,64}$.Stable message identifier from search results. Format:
imap:{account_id}:{mailbox}:{uidvalidity}:{uid}.Validation:- Must start with
imap:prefix uidvalidityanduidmust be non-negative integers- Parsed
account_idmust match theaccount_idparameter - Mailbox name must be 1-256 characters
Maximum message size in bytes to retrieve. Range: 1,024-1,000,000 (1 KB to ~1 MB).If the actual message size exceeds this limit, the operation fails with an
invalid_input error instructing you to increase max_bytes.Output Data
Operation status:
ok (success), partial (some operations failed), or failed (operation failed).Array of diagnostic issues encountered during the operation.
Account identifier used for this operation.
Stable message identifier that was retrieved.
URI reference to the message resource (e.g.,
imap://default/mailbox/INBOX/message/123456/789).URI reference to the raw RFC822 message source (this resource).
Actual message size in bytes. This is the size of the raw message before base64 encoding.On success, this will be ≤
max_bytes. If the message is larger than max_bytes, the operation fails.Complete RFC822 message source encoded as base64. The base64 string can be decoded to obtain the original byte-faithful message.Returns
null when status=failed.Encoding format for
raw_source_base64. Always "base64" on success, null on failure.Size Limits and Behavior
Maximum Size
- Default: 200,000 bytes (~200 KB)
- Range: 1,024-1,000,000 bytes (1 KB to ~1 MB)
- Enforcement: Size is checked after fetching the complete message
When Message Exceeds max_bytes
If the actual message size is larger thanmax_bytes, the operation fails with:
max_bytes value (up to 1,000,000).
Base64 Encoding
Theraw_source_base64 field contains the message bytes encoded using standard base64 encoding:
- Alphabet:
A-Z,a-z,0-9,+,/ - Padding:
=characters as needed - Line breaks: No line breaks in the encoded string
Decoding Example (JavaScript)
Decoding Example (Python)
UIDVALIDITY Validation
The server validates that the mailbox UIDVALIDITY in themessage_id matches the current mailbox state. If the UIDVALIDITY has changed, the operation fails with a conflict error:
Example: Fetch Small Message
Request:Example: Fetch Large Message
Request:Example: Message Too Large
Request:max_bytes:
Example: Connection Failure
Response:Use Cases
Diagnostics and Debugging
Retrieve the raw message source to:- Inspect complete MIME structure
- Diagnose encoding issues
- Analyze malformed headers
- Debug attachment problems
Message Export and Archival
Save messages in standard RFC822 format for:- Long-term archival
- Migration to other systems
- Backup and disaster recovery
- Compliance and legal holds
Advanced Processing
Provide raw message data to:- Custom MIME parsers
- Machine learning pipelines
- Security scanning tools
- Email forensics applications
Validation Errors
Invalid message_id Format
Account Mismatch
Size Limit Out of Range
UIDVALIDITY Conflict
Related Tools
- imap_get_message - Get parsed message with structured data
- imap_search_messages - Search for messages to get message IDs
- imap_copy_message - Copy message to another mailbox