feat(docs): Update documentation to include consolidated email handling and pattern‑based routing details
This commit is contained in:
145
readme.md
145
readme.md
@ -103,38 +103,153 @@ async function sendLetter() {
|
||||
sendLetter();
|
||||
```
|
||||
|
||||
### Mail Transfer Agent (MTA)
|
||||
### Mail Transfer Agent (MTA) and Consolidated Email Handling
|
||||
|
||||
The platform includes a robust Mail Transfer Agent (MTA) for enterprise-grade email handling with complete control over the email delivery process:
|
||||
The platform includes a robust Mail Transfer Agent (MTA) for enterprise-grade email handling with complete control over the email delivery process.
|
||||
Additionally, the platform now features a consolidated email configuration system with pattern-based routing:
|
||||
|
||||
```mermaid
|
||||
graph TD
|
||||
API[API Clients] --> ApiManager
|
||||
SMTP[External SMTP Servers] <--> SMTPServer
|
||||
SMTP[External SMTP Servers] <--> UnifiedEmailServer
|
||||
|
||||
subgraph "DcRouter Email System"
|
||||
DcRouter[DcRouter] --> UnifiedEmailServer[Unified Email Server]
|
||||
DcRouter --> DomainRouter[Domain Router]
|
||||
UnifiedEmailServer --> MultiModeProcessor[Multi-Mode Processor]
|
||||
MultiModeProcessor --> ForwardMode[Forward Mode]
|
||||
MultiModeProcessor --> MtaMode[MTA Mode]
|
||||
MultiModeProcessor --> ProcessMode[Process Mode]
|
||||
ApiManager[API Manager] --> DcRouter
|
||||
end
|
||||
|
||||
subgraph "MTA Service"
|
||||
MtaService[MTA Service] --> SMTPServer[SMTP Server]
|
||||
MtaMode --> MtaService[MTA Service]
|
||||
MtaService --> EmailSendJob[Email Send Job]
|
||||
MtaService --> DnsManager[DNS Manager]
|
||||
MtaService --> DkimCreator[DKIM Creator]
|
||||
ApiManager[API Manager] --> MtaService
|
||||
end
|
||||
|
||||
subgraph "External Services"
|
||||
DnsManager <--> DNS[DNS Servers]
|
||||
EmailSendJob <--> MXServers[MX Servers]
|
||||
ForwardMode <--> ExternalSMTP[External SMTP Servers]
|
||||
end
|
||||
```
|
||||
|
||||
The MTA service provides:
|
||||
- Complete SMTP server for receiving emails
|
||||
- DKIM signing and verification
|
||||
- SPF and DMARC support
|
||||
- DNS record management
|
||||
- Retry logic with queue processing
|
||||
- TLS encryption
|
||||
#### Key Features
|
||||
|
||||
Here's how to use the MTA service:
|
||||
The email handling system provides:
|
||||
- **Pattern-based Routing**: Route emails based on glob patterns like `*@domain.com` or `*@*.domain.com`
|
||||
- **Multi-Modal Processing**: Handle different email domains with different processing modes:
|
||||
- **Forward Mode**: SMTP forwarding to other servers
|
||||
- **MTA Mode**: Full Mail Transfer Agent capabilities
|
||||
- **Process Mode**: Store-and-forward with content scanning
|
||||
- **Unified Configuration**: Single configuration interface for all email handling
|
||||
- **Shared Infrastructure**: Use same ports (25, 587, 465) for all email handling
|
||||
- **Complete SMTP Server**: Receive emails with TLS and authentication support
|
||||
- **DKIM, SPF, DMARC**: Full email authentication standard support
|
||||
- **Content Scanning**: Check for spam, viruses, and other threats
|
||||
- **Advanced Delivery Management**: Queue, retry, and track delivery status
|
||||
|
||||
#### Using the Consolidated Email System
|
||||
|
||||
Here's how to use the consolidated email system:
|
||||
|
||||
```ts
|
||||
import { DcRouter, IEmailConfig, EmailProcessingMode } from '@serve.zone/platformservice';
|
||||
|
||||
async function setupEmailHandling() {
|
||||
// Configure the email handling system
|
||||
const dcRouter = new DcRouter({
|
||||
emailConfig: {
|
||||
ports: [25, 587, 465],
|
||||
hostname: 'mail.example.com',
|
||||
|
||||
// TLS configuration
|
||||
tls: {
|
||||
certPath: '/path/to/cert.pem',
|
||||
keyPath: '/path/to/key.pem'
|
||||
},
|
||||
|
||||
// Default handling for unmatched domains
|
||||
defaultMode: 'forward' as EmailProcessingMode,
|
||||
defaultServer: 'fallback.mail.example.com',
|
||||
defaultPort: 25,
|
||||
|
||||
// Pattern-based routing rules
|
||||
domainRules: [
|
||||
{
|
||||
// Forward all company.com emails to internal mail server
|
||||
pattern: '*@company.com',
|
||||
mode: 'forward' as EmailProcessingMode,
|
||||
target: {
|
||||
server: 'internal-mail.company.local',
|
||||
port: 25,
|
||||
useTls: true
|
||||
}
|
||||
},
|
||||
{
|
||||
// Process notifications.company.com with MTA
|
||||
pattern: '*@notifications.company.com',
|
||||
mode: 'mta' as EmailProcessingMode,
|
||||
mtaOptions: {
|
||||
domain: 'notifications.company.com',
|
||||
dkimSign: true,
|
||||
dkimOptions: {
|
||||
domainName: 'notifications.company.com',
|
||||
keySelector: 'mail',
|
||||
privateKey: '...'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
// Scan marketing emails for content and transform
|
||||
pattern: '*@marketing.company.com',
|
||||
mode: 'process' as EmailProcessingMode,
|
||||
contentScanning: true,
|
||||
scanners: [
|
||||
{
|
||||
type: 'spam',
|
||||
threshold: 5.0,
|
||||
action: 'tag'
|
||||
}
|
||||
],
|
||||
transformations: [
|
||||
{
|
||||
type: 'addHeader',
|
||||
header: 'X-Marketing',
|
||||
value: 'true'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
// Start the system
|
||||
await dcRouter.start();
|
||||
console.log('DcRouter with email handling started');
|
||||
|
||||
// Later, you can update rules dynamically
|
||||
await dcRouter.updateDomainRules([
|
||||
{
|
||||
pattern: '*@newdomain.com',
|
||||
mode: 'forward' as EmailProcessingMode,
|
||||
target: {
|
||||
server: 'mail.newdomain.com',
|
||||
port: 25
|
||||
}
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
||||
setupEmailHandling();
|
||||
```
|
||||
|
||||
#### Using the MTA Service Directly
|
||||
|
||||
You can still use the MTA service directly for more granular control:
|
||||
|
||||
```ts
|
||||
import { MtaService, Email } from '@serve.zone/platformservice';
|
||||
@ -170,7 +285,9 @@ async function useMtaService() {
|
||||
useMtaService();
|
||||
```
|
||||
|
||||
The MTA provides key advantages for applications requiring:
|
||||
The consolidated email system provides key advantages for applications requiring:
|
||||
- Domain-specific email handling
|
||||
- Flexible email routing
|
||||
- High-volume email sending
|
||||
- Compliance with email authentication standards
|
||||
- Detailed delivery tracking
|
||||
|
Reference in New Issue
Block a user