sequenceDiagram
participant C as Email Client
participant S as SMTP Server
participant Q as Mail Queue
participant R as Message Router
participant D as DKIM Signer
participant ST as Storage
participant I as IMAP Server
Note over C,I: Email Sending Flow
C->>S: SMTP Connection
S->>C: 220 Ready
C->>S: EHLO client.domain
S->>C: 250 Hello
C->>S: MAIL FROM: sender@domain.com
S->>C: 250 OK
C->>S: RCPT TO: recipient@domain.com
S->>C: 250 OK
C->>S: DATA
C->>S: Email Content
S->>C: 250 Queued
S->>Q: Add to Queue
Q->>R: Process Message
R->>D: Sign with DKIM
D->>R: Signed Message
R->>ST: Store Message
ST->>R: Store Confirmation
Note over C,I: Email Retrieval Flow
C->>I: IMAP Connection
I->>C: 220 Ready
C->>I: LOGIN user pass
I->>C: OK Authenticated
C->>I: SELECT INBOX
I->>ST: Fetch Messages
ST->>I: Message List
I->>C: Message Headers
C->>I: FETCH 1 RFC822
I->>ST: Get Full Message
ST->>I: Message Content
I->>C: Email Content
- SMTP Reception - Accept incoming connections
- Authentication - Verify sender credentials
- Queue Processing - Add to delivery queue
- Security Checks - SPF, DKIM, DMARC validation
- Message Storage - Persist to database
- Notification - Update mailbox indexes
- Message Composition - Create email content
- DKIM Signing - Cryptographic signature
- Queue Management - Add to outbound queue
- DNS Resolution - Find MX records
- Delivery Attempt - Send to destination
- Bounce Handling - Process delivery failures
- Query Processing - Parse search criteria
- Index Lookup - Search optimized indexes
- Result Assembly - Gather matching messages
- Permission Check - Verify access rights
- Response Formatting - Structure output
- Client Delivery - Send to application
- Message Headers: Frequently accessed metadata
- Authentication Tokens: Session credentials
- DNS Results: MX record lookups
- Configuration: Runtime settings
- Message Delivery: Concurrent outbound sending
- Mailbox Sync: Parallel IMAP operations
- Search Queries: Multi-threaded indexing
- Log Writing: Asynchronous audit trails
- Horizontal Scaling: Multi-node deployment
- Load Balancing: Distributed request handling
- Data Sharding: Partitioned message storage
- Connection Pooling: Reused database connections