fix(structure): Unify structure even further
This commit is contained in:
@ -11,7 +11,7 @@ export interface IAttachment {
|
||||
|
||||
export interface IEmailOptions {
|
||||
from: string;
|
||||
to: string | string[]; // Support multiple recipients
|
||||
to?: string | string[]; // Optional for templates
|
||||
cc?: string | string[]; // Optional CC recipients
|
||||
bcc?: string | string[]; // Optional BCC recipients
|
||||
subject: string;
|
||||
@ -68,16 +68,14 @@ export class Email {
|
||||
this.from = options.from;
|
||||
|
||||
// Handle to addresses (single or multiple)
|
||||
this.to = this.parseRecipients(options.to);
|
||||
this.to = options.to ? this.parseRecipients(options.to) : [];
|
||||
|
||||
// Handle optional cc and bcc
|
||||
this.cc = options.cc ? this.parseRecipients(options.cc) : [];
|
||||
this.bcc = options.bcc ? this.parseRecipients(options.bcc) : [];
|
||||
|
||||
// Validate that we have at least one recipient
|
||||
if (this.to.length === 0 && this.cc.length === 0 && this.bcc.length === 0) {
|
||||
throw new Error('Email must have at least one recipient');
|
||||
}
|
||||
// Note: Templates may be created without recipients
|
||||
// Recipients will be added when the email is actually sent
|
||||
|
||||
// Set subject with sanitization
|
||||
this.subject = this.sanitizeString(options.subject || '');
|
||||
|
Reference in New Issue
Block a user