feat(structure): Use unified Email class

This commit is contained in:
2025-05-27 15:38:34 +00:00
parent cfea44742a
commit 243a45d24c
11 changed files with 546 additions and 143 deletions

View File

@ -499,6 +499,41 @@ public getSmtpClient(host: string, port: number = 25): SmtpClient {
- This provides access to SMTP clients, DKIM signing, and other shared functionality
- Example: `new EmailSendJob(emailServerRef, email, options)`
## Email Class Standardization (2025-05-27) - COMPLETED
### Overview
The entire codebase has been standardized to use the `Email` class as the single data structure for email handling. All Smartmail usage has been eliminated.
### Key Changes
1. **Email Class Enhanced** - Added compatibility methods: `getSubject()`, `getBody(isHtml)`, `getFrom()`
2. **BounceManager** - Now accepts `Email` objects directly
3. **TemplateManager** - Returns `Email` objects instead of Smartmail
4. **EmailService** - `sendEmail()` accepts `Email` objects
5. **RuleManager** - Uses `SmartRule<Email>` instead of `SmartRule<Smartmail>`
6. **ApiManager** - Creates `Email` objects for API requests
### Benefits
- No more Email ↔ Smartmail conversions
- Consistent API throughout (`email.subject` not `smartmail.options.subject`)
- Better performance (no conversion overhead)
- Simpler, more maintainable code
### Usage Pattern
```typescript
// Create email
const email = new Email({
from: 'sender@example.com',
to: 'recipient@example.com',
subject: 'Hello',
text: 'World'
});
// Pass directly through system
await bounceManager.processBounceEmail(email);
await templateManager.prepareEmail(templateId, context);
await emailService.sendEmail(email);
```
## Email Class Design Pattern (2025-05-27)
### Three-Interface Pattern for Email