mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Improved MIME email addresses parse info
This commit is contained in:
parent
ec9197cb85
commit
be8d302b82
4 changed files with 34 additions and 12 deletions
|
|
@ -16,12 +16,13 @@ export function ParseMime(text)
|
||||||
this.boundary = '';
|
this.boundary = '';
|
||||||
this.bodyText = '';
|
this.bodyText = '';
|
||||||
// https://datatracker.ietf.org/doc/html/rfc2822#section-3.6
|
// https://datatracker.ietf.org/doc/html/rfc2822#section-3.6
|
||||||
|
// https://datatracker.ietf.org/doc/html/rfc4021
|
||||||
this.headers = {
|
this.headers = {
|
||||||
// Required
|
// Required
|
||||||
date = null,
|
date = null,
|
||||||
from = [], // mailbox-list
|
from = [], // mailbox-list
|
||||||
// Optional
|
// Optional
|
||||||
sender = [], // MUST occur with multi-address
|
sender = [], // mailbox MUST occur with multi-address
|
||||||
'reply-to' = [], // address-list
|
'reply-to' = [], // address-list
|
||||||
to = [], // address-list
|
to = [], // address-list
|
||||||
cc = [], // address-list
|
cc = [], // address-list
|
||||||
|
|
@ -34,7 +35,6 @@ export function ParseMime(text)
|
||||||
comments = [], // unstructured
|
comments = [], // unstructured
|
||||||
keywords = [], // phrase *("," phrase)
|
keywords = [], // phrase *("," phrase)
|
||||||
// https://datatracker.ietf.org/doc/html/rfc2822#section-3.6.6
|
// https://datatracker.ietf.org/doc/html/rfc2822#section-3.6.6
|
||||||
trace = [],
|
|
||||||
'resent-date' = [],
|
'resent-date' = [],
|
||||||
'resent-from' = [],
|
'resent-from' = [],
|
||||||
'resent-sender' = [],
|
'resent-sender' = [],
|
||||||
|
|
@ -42,13 +42,15 @@ export function ParseMime(text)
|
||||||
'resent-cc' = [],
|
'resent-cc' = [],
|
||||||
'resent-bcc' = [],
|
'resent-bcc' = [],
|
||||||
'resent-msg-id' = [],
|
'resent-msg-id' = [],
|
||||||
|
// https://datatracker.ietf.org/doc/html/rfc2822#section-3.6.7
|
||||||
|
trace = [],
|
||||||
|
'return-path' = '', // angle-addr
|
||||||
|
received = [],
|
||||||
// optional others outside RFC2822
|
// optional others outside RFC2822
|
||||||
'mime-version' = '',
|
'mime-version' = '', // RFC2045
|
||||||
'content-transfer-encoding' = '',
|
'content-transfer-encoding' = '',
|
||||||
'content-type' = '',
|
'content-type' = '',
|
||||||
'delivered-to' = '', // angle-addr
|
'delivered-to' = [], // RFC9228 addr-spec
|
||||||
'return-path' = '', // angle-addr
|
|
||||||
'received' = [],
|
|
||||||
'authentication-results' = '', // dkim, spf, dmarc
|
'authentication-results' = '', // dkim, spf, dmarc
|
||||||
'dkim-signature' = '',
|
'dkim-signature' = '',
|
||||||
'x-rspamd-queue-id' = '',
|
'x-rspamd-queue-id' = '',
|
||||||
|
|
@ -57,6 +59,7 @@ export function ParseMime(text)
|
||||||
'x-rspamd-server' = '',
|
'x-rspamd-server' = '',
|
||||||
'x-spamd-result' = '',
|
'x-spamd-result' = '',
|
||||||
'x-remote-address' = '',
|
'x-remote-address' = '',
|
||||||
|
// etc.
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,6 @@ export function MimeToMessage(data, message)
|
||||||
const text = struct.getByContentType('text/plain');
|
const text = struct.getByContentType('text/plain');
|
||||||
message.plain(text ? text.body : '');
|
message.plain(text ? text.body : '');
|
||||||
message.html(html);
|
message.html(html);
|
||||||
console.dir({message});
|
|
||||||
} else {
|
} else {
|
||||||
message.plain(data);
|
message.plain(data);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -235,11 +235,11 @@ export class MessageModel extends AbstractModel {
|
||||||
this.messageId = headers.valueByName('Message-Id');
|
this.messageId = headers.valueByName('Message-Id');
|
||||||
this.subject(headers.valueByName('Subject'));
|
this.subject(headers.valueByName('Subject'));
|
||||||
this.sender = EmailCollectionModel.fromString(headers.valueByName('Sender'));
|
this.sender = EmailCollectionModel.fromString(headers.valueByName('Sender'));
|
||||||
this.from = EmailCollectionModel.fromString(headers.valueByName('From'));
|
this.from = EmailCollectionModel.fromArray(headers.valueByName('From'));
|
||||||
this.replyTo = EmailCollectionModel.fromString(headers.valueByName('Reply-To'));
|
this.replyTo = EmailCollectionModel.fromArray(headers.valueByName('Reply-To'));
|
||||||
this.to = EmailCollectionModel.fromString(headers.valueByName('To'));
|
this.to = EmailCollectionModel.fromArray(headers.valueByName('To'));
|
||||||
this.cc = EmailCollectionModel.fromString(headers.valueByName('Cc'));
|
this.cc = EmailCollectionModel.fromArray(headers.valueByName('Cc'));
|
||||||
this.bcc = EmailCollectionModel.fromString(headers.valueByName('Bcc'));
|
this.bcc = EmailCollectionModel.fromArray(headers.valueByName('Bcc'));
|
||||||
this.inReplyTo = headers.valueByName('In-Reply-To');
|
this.inReplyTo = headers.valueByName('In-Reply-To');
|
||||||
|
|
||||||
this.deliveredTo = EmailCollectionModel.fromString(headers.valueByName('Delivered-To'));
|
this.deliveredTo = EmailCollectionModel.fromString(headers.valueByName('Delivered-To'));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue