Improved MIME email addresses parse info

This commit is contained in:
the-djmaze 2024-02-04 23:25:31 +01:00
parent ec9197cb85
commit be8d302b82
4 changed files with 34 additions and 12 deletions

View file

@ -52,4 +52,24 @@ export class EmailCollectionModel extends AbstractCollectionModel
}
}
/**
* @param {array} [{name: "Name", email: "address@domain"}]
*/
/*
static fromArray(addresses) {
let list = new this();
list.fromArray(addresses);
return list;
}
fromArray(addresses) {
addresses.forEach(item => {
item = new EmailModel(item.email, item.name);
// Make them unique
if (item.email && item.name || !this.find(address => address.email == item.email)) {
this.push(item);
}
});
}
*/
}

View file

@ -235,11 +235,11 @@ export class MessageModel extends AbstractModel {
this.messageId = headers.valueByName('Message-Id');
this.subject(headers.valueByName('Subject'));
this.sender = EmailCollectionModel.fromString(headers.valueByName('Sender'));
this.from = EmailCollectionModel.fromString(headers.valueByName('From'));
this.replyTo = EmailCollectionModel.fromString(headers.valueByName('Reply-To'));
this.to = EmailCollectionModel.fromString(headers.valueByName('To'));
this.cc = EmailCollectionModel.fromString(headers.valueByName('Cc'));
this.bcc = EmailCollectionModel.fromString(headers.valueByName('Bcc'));
this.from = EmailCollectionModel.fromArray(headers.valueByName('From'));
this.replyTo = EmailCollectionModel.fromArray(headers.valueByName('Reply-To'));
this.to = EmailCollectionModel.fromArray(headers.valueByName('To'));
this.cc = EmailCollectionModel.fromArray(headers.valueByName('Cc'));
this.bcc = EmailCollectionModel.fromArray(headers.valueByName('Bcc'));
this.inReplyTo = headers.valueByName('In-Reply-To');
this.deliveredTo = EmailCollectionModel.fromString(headers.valueByName('Delivered-To'));