postal-mime 2.2.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/README.md +5 -2
- package/package.json +1 -1
- package/postal-mime.d.ts +1 -0
- package/src/postal-mime.js +18 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.2.1](https://github.com/postalsys/postal-mime/compare/v2.2.0...v2.2.1) (2024-03-31)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **parser:** Reply-To value must be an array, not a single address object ([280bd8d](https://github.com/postalsys/postal-mime/commit/280bd8dc1626315e1a43f35641415453c434716e))
|
|
9
|
+
|
|
3
10
|
## [2.2.0](https://github.com/postalsys/postal-mime/compare/v2.1.2...v2.2.0) (2024-03-26)
|
|
4
11
|
|
|
5
12
|
|
package/README.md
CHANGED
|
@@ -4,6 +4,9 @@ Email parser for browser and serverless environments.
|
|
|
4
4
|
|
|
5
5
|
PostalMime can be run in the main web thread or from Web Workers. It can also used in serverless functions.
|
|
6
6
|
|
|
7
|
+
> [!TIP]
|
|
8
|
+
> PostalMime is developed by the makers of **[EmailEngine](https://emailengine.app/?utm_source=github&utm_campaign=imapflow&utm_medium=readme-link)** – a self-hosted email gateway that allows making **REST requests against IMAP and SMTP servers**. EmailEngine also sends webhooks whenever something changes on the registered accounts.
|
|
9
|
+
|
|
7
10
|
## Source
|
|
8
11
|
|
|
9
12
|
The source code is available from [Github](https://github.com/postalsys/postal-mime).
|
|
@@ -100,11 +103,11 @@ This method parses an email message into a structured object with the following
|
|
|
100
103
|
- **headers** is an array of headers in the same order as found from the message (topmost headers first).
|
|
101
104
|
- **headers[].key** is lowercase key of the header line, eg. `"dkim-signature"`
|
|
102
105
|
- **headers[].value** is the unprocessed value of the header line
|
|
103
|
-
- **from**, **sender
|
|
106
|
+
- **from**, **sender** includes a processed object for the corresponding headers
|
|
104
107
|
- **from.name** is decoded name (empty string if not set)
|
|
105
108
|
- **from.address** is the email address
|
|
106
109
|
- **deliveredTo**, **returnPath** is the email address from the corresponding header
|
|
107
|
-
- **to**, **cc**, **bcc** includes an array of processed objects for the corresponding headers
|
|
110
|
+
- **to**, **cc**, **bcc**, **replyTo** includes an array of processed objects for the corresponding headers
|
|
108
111
|
- **to[].name** is decoded name (empty string if not set)
|
|
109
112
|
- **to[].address** is the email address
|
|
110
113
|
- **subject** is the email subject line
|
package/package.json
CHANGED
package/postal-mime.d.ts
CHANGED
package/src/postal-mime.js
CHANGED
|
@@ -358,32 +358,33 @@ export default class PostalMime {
|
|
|
358
358
|
|
|
359
359
|
await this.processNodeTree();
|
|
360
360
|
|
|
361
|
-
|
|
361
|
+
const message = {
|
|
362
362
|
headers: this.root.headers.map(entry => ({ key: entry.key, value: entry.value })).reverse()
|
|
363
363
|
};
|
|
364
364
|
|
|
365
|
-
for (
|
|
366
|
-
|
|
365
|
+
for (const key of ['from', 'sender']) {
|
|
366
|
+
const addressHeader = this.root.headers.find(line => line.key === key);
|
|
367
367
|
if (addressHeader && addressHeader.value) {
|
|
368
|
-
|
|
368
|
+
const addresses = addressParser(addressHeader.value);
|
|
369
369
|
if (addresses && addresses.length) {
|
|
370
|
-
message[key
|
|
370
|
+
message[key] = addresses[0];
|
|
371
371
|
}
|
|
372
372
|
}
|
|
373
373
|
}
|
|
374
374
|
|
|
375
|
-
for (
|
|
376
|
-
|
|
375
|
+
for (const key of ['delivered-to', 'return-path']) {
|
|
376
|
+
const addressHeader = this.root.headers.find(line => line.key === key);
|
|
377
377
|
if (addressHeader && addressHeader.value) {
|
|
378
|
-
|
|
378
|
+
const addresses = addressParser(addressHeader.value);
|
|
379
379
|
if (addresses && addresses.length && addresses[0].address) {
|
|
380
|
-
|
|
380
|
+
const camelKey = key.replace(/\-(.)/g, (o, c) => c.toUpperCase());
|
|
381
|
+
message[camelKey] = addresses[0].address;
|
|
381
382
|
}
|
|
382
383
|
}
|
|
383
384
|
}
|
|
384
385
|
|
|
385
|
-
for (
|
|
386
|
-
|
|
386
|
+
for (const key of ['to', 'cc', 'bcc', 'reply-to']) {
|
|
387
|
+
const addressHeaders = this.root.headers.filter(line => line.key === key);
|
|
387
388
|
let addresses = [];
|
|
388
389
|
|
|
389
390
|
addressHeaders
|
|
@@ -392,14 +393,16 @@ export default class PostalMime {
|
|
|
392
393
|
.forEach(parsed => (addresses = addresses.concat(parsed || [])));
|
|
393
394
|
|
|
394
395
|
if (addresses && addresses.length) {
|
|
395
|
-
|
|
396
|
+
const camelKey = key.replace(/\-(.)/g, (o, c) => c.toUpperCase());
|
|
397
|
+
message[camelKey] = addresses;
|
|
396
398
|
}
|
|
397
399
|
}
|
|
398
400
|
|
|
399
|
-
for (
|
|
400
|
-
|
|
401
|
+
for (const key of ['subject', 'message-id', 'in-reply-to', 'references']) {
|
|
402
|
+
const header = this.root.headers.find(line => line.key === key);
|
|
401
403
|
if (header && header.value) {
|
|
402
|
-
|
|
404
|
+
const camelKey = key.replace(/\-(.)/g, (o, c) => c.toUpperCase());
|
|
405
|
+
message[camelKey] = decodeWords(header.value);
|
|
403
406
|
}
|
|
404
407
|
}
|
|
405
408
|
|