fix(structure): Unify structure even further
This commit is contained in:
@ -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'];
|
||||
```
|
Reference in New Issue
Block a user