Emails Management
Relevant source files
The following files were used as context for generating this wiki page:
Emails Management handles the creation, delivery, and lifecycle of outbound and inbound communications. It provides tools for sending transactional emails, managing scheduled deliveries, and interacting with inbox-specific resources like drafts and threads.
Email Service Architecture
The Email service acts as the primary interface for standard email operations. It manages outbound emails and integrates sub-services for specialized tasks like attachments and receiving.
The diagram shows the Email service inheriting from a base Service class and delegating specialized email tasks to sub-service instances.
Sources: src/Service/Email.php:11-30
Core Operations
The service supports several high-level operations for managing email resources:
- Sending: Initiates email delivery through the
send()orcreate()methods. - Scheduling: Updates or cancels emails that are set to be sent in the future.
- Metrics: Retrieves delivery and engagement data, such as open and click rates.
- Sharing: Generates shareable URLs for specific sent or received emails.
Sources: src/Service/Email.php:48-112, tests/Service/Email.php:24-81
Inbox and Draft Management
Inboxes manage collaborative email communication through threads and drafts. Drafts represent unsent messages that can either start a new thread or reply to an existing one.
Draft Lifecycle
A draft transitions from creation to update and finally to a sent state, which converts the draft into an outbound email.
This flowchart illustrates the lifecycle of an inbox draft resource.
Sources: tests/Service/Inboxes/Draft.php:26-121, src/Inboxes/Draft.php:25-27
Thread Interaction
Threads group related emails together. You can perform actions on specific emails within a thread:
- List/Get: Retrieve all emails or a specific email within a thread context.
- Reply: Send a response to a specific message in a thread.
- Forward: Direct a thread email to a new recipient.
Sources: tests/Service/Inboxes/Threads/Email.php:7-60, src/Inboxes/Thread.php:12-23
Email Metrics and Analytics
The metrics system aggregates delivery and engagement data across different dimensions.
| Dimension | Description |
|---|---|
period | Aggregates data based on time intervals. |
domain | Groups metrics by the sending domain. |
email | Tracks metrics for specific email IDs. |
broadcast | Tracks metrics for specific marketing broadcasts. |
Cautions: You cannot combine the broadcast dimension or filter with the email dimension or filter.
Sources: src/Service/Email.php:115-150, tests/Service/Email.php:181-220
Metrics Data Flow
This sequence diagram shows how the metrics method processes options and validates constraints before making the API request.
Sources: src/Service/Email.php:115-174
Data Models
Email Resource Structure
| Field | Type | Description |
|---|---|---|
id | string | Unique identifier for the email. |
message_id | string | The ID of the message on the mail server. |
from | string | The sender's email address. |
to | string/array | The recipient(s) of the email. |
created_at | string | ISO timestamp of creation. |
Sources: tests/Fixtures/Email.php:5-13, tests/Fixtures/Emails/Receiving.php:5-24
Draft Properties
Drafts contain specific metadata for thread management:
type: Eitherstandalone(new thread) orreply(existing thread).thread_id: The ID of the thread if the draft is a reply.reply_to_email_id: The specific email being replied to.attachments: An array containingid,filename,content_type, andsize.
Sources: src/Inboxes/Draft.php:13-26
Summary
Emails Management provides a unified interface for handling both standard transactional emails and complex inbox-based interactions. It ensures technical accuracy through strict dimension validation in metrics and supports the full lifecycle of drafts and threads, enabling robust communication features within the application.