fix(structure): Unify structure even further

This commit is contained in:
2025-05-27 18:00:14 +00:00
parent 243a45d24c
commit 2aeb52bf13
10 changed files with 231 additions and 115 deletions

View File

@ -609,4 +609,27 @@ email.to.forEach(recipient => {
// Convert back to options format
const optionsAgain = email.toEmailOptions();
```
### Template Email Creation (2025-05-27)
The Email class now supports template creation without recipients:
- IEmailOptions 'to' field is now optional (for templates)
- Email constructor allows creation without recipients
- Recipients are added later when the email is actually sent
```typescript
// Template creation (no recipients)
const emailOptions: IEmailOptions = {
from: 'noreply@example.com',
subject: 'Welcome {{name}}',
text: 'Hello {{name}}!',
// 'to' is omitted for templates
variables: { name: 'User' }
};
const templateEmail = new Email(emailOptions);
// templateEmail.to is an empty array []
// Later, when sending:
templateEmail.to = ['recipient@example.com'];
```