Initial
This commit is contained in:
1
test/imaps/node_modules/mailparser/.gitattributes
generated
vendored
Normal file
1
test/imaps/node_modules/mailparser/.gitattributes
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.js text eol=lf
|
||||
4
test/imaps/node_modules/mailparser/.github/FUNDING.yml
generated
vendored
Normal file
4
test/imaps/node_modules/mailparser/.github/FUNDING.yml
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: [andris9] # enable once enrolled
|
||||
custom: ['https://www.paypal.me/nodemailer']
|
||||
21
test/imaps/node_modules/mailparser/.github/workflows/test.yml
generated
vendored
Normal file
21
test/imaps/node_modules/mailparser/.github/workflows/test.yml
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
name: Run tests
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
strategy:
|
||||
matrix:
|
||||
node: [14.x, 16.x, 18.x]
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Use Node.js ${{ matrix.node }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
- run: npm install
|
||||
- run: npm test
|
||||
8
test/imaps/node_modules/mailparser/.prettierrc.js
generated
vendored
Normal file
8
test/imaps/node_modules/mailparser/.prettierrc.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
module.exports = {
|
||||
printWidth: 160,
|
||||
tabWidth: 4,
|
||||
singleQuote: true,
|
||||
endOfLine: 'lf',
|
||||
trailingComma: 'none',
|
||||
arrowParens: 'avoid'
|
||||
};
|
||||
16
test/imaps/node_modules/mailparser/LICENSE
generated
vendored
Normal file
16
test/imaps/node_modules/mailparser/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
Copyright (c) 2020 - 2021 Andris Reinman
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
31
test/imaps/node_modules/mailparser/README.md
generated
vendored
Normal file
31
test/imaps/node_modules/mailparser/README.md
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
# mailparser
|
||||
|
||||

|
||||
|
||||
Advanced email parser for Node.js. Everything is handled as a stream which should make it able to parse even very large messages (100MB+) with relatively low overhead.
|
||||
|
||||
## Looking for a front-end solution?
|
||||
|
||||
_mailparser_ is Node.js only library, so you can't use it reliably in the front-end or bundle with WebPack. If you do need a solution to parse emails in the front-end then use [PostalMime](https://www.npmjs.com/package/postal-mime).
|
||||
|
||||
## Installation
|
||||
|
||||
First install the module from npm:
|
||||
|
||||
```
|
||||
$ npm install mailparser
|
||||
```
|
||||
|
||||
next import the `mailparser` object into your script:
|
||||
|
||||
```js
|
||||
const mailparser = require('mailparser');
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
See [mailparser homepage](https://nodemailer.com/extras/mailparser/) for documentation and terms.
|
||||
|
||||
### License
|
||||
|
||||
Licensed under MIT
|
||||
9
test/imaps/node_modules/mailparser/index.js
generated
vendored
Normal file
9
test/imaps/node_modules/mailparser/index.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const MailParser = require('./lib/mail-parser');
|
||||
const simpleParser = require('./lib/simple-parser');
|
||||
|
||||
module.exports = {
|
||||
MailParser,
|
||||
simpleParser
|
||||
};
|
||||
1160
test/imaps/node_modules/mailparser/lib/mail-parser.js
generated
vendored
Normal file
1160
test/imaps/node_modules/mailparser/lib/mail-parser.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
137
test/imaps/node_modules/mailparser/lib/simple-parser.js
generated
vendored
Normal file
137
test/imaps/node_modules/mailparser/lib/simple-parser.js
generated
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
'use strict';
|
||||
|
||||
const MailParser = require('./mail-parser.js');
|
||||
|
||||
module.exports = (input, options, callback) => {
|
||||
if (input === null || input === undefined) {
|
||||
throw new TypeError('Input cannot be null or undefined.');
|
||||
}
|
||||
|
||||
if (!callback && typeof options === 'function') {
|
||||
callback = options;
|
||||
options = false;
|
||||
}
|
||||
|
||||
let promise;
|
||||
if (!callback) {
|
||||
promise = new Promise((resolve, reject) => {
|
||||
callback = callbackPromise(resolve, reject);
|
||||
});
|
||||
}
|
||||
|
||||
options = options || {};
|
||||
let keepCidLinks = !!options.keepCidLinks;
|
||||
|
||||
let mail = {
|
||||
attachments: []
|
||||
};
|
||||
|
||||
let parser = new MailParser(options);
|
||||
|
||||
parser.on('error', err => {
|
||||
callback(err);
|
||||
});
|
||||
|
||||
parser.on('headers', headers => {
|
||||
mail.headers = headers;
|
||||
mail.headerLines = parser.headerLines;
|
||||
});
|
||||
|
||||
let reading = false;
|
||||
let reader = () => {
|
||||
reading = true;
|
||||
|
||||
let data = parser.read();
|
||||
|
||||
if (data === null) {
|
||||
reading = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.type === 'text') {
|
||||
Object.keys(data).forEach(key => {
|
||||
if (['text', 'html', 'textAsHtml'].includes(key)) {
|
||||
mail[key] = data[key];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (data.type === 'attachment') {
|
||||
mail.attachments.push(data);
|
||||
|
||||
let chunks = [];
|
||||
let chunklen = 0;
|
||||
data.content.on('readable', () => {
|
||||
let chunk;
|
||||
while ((chunk = data.content.read()) !== null) {
|
||||
chunks.push(chunk);
|
||||
chunklen += chunk.length;
|
||||
}
|
||||
});
|
||||
|
||||
data.content.on('end', () => {
|
||||
data.content = Buffer.concat(chunks, chunklen);
|
||||
data.release();
|
||||
reader();
|
||||
});
|
||||
} else {
|
||||
reader();
|
||||
}
|
||||
};
|
||||
|
||||
parser.on('readable', () => {
|
||||
if (!reading) {
|
||||
reader();
|
||||
}
|
||||
});
|
||||
|
||||
parser.on('end', () => {
|
||||
['subject', 'references', 'date', 'to', 'from', 'to', 'cc', 'bcc', 'message-id', 'in-reply-to', 'reply-to'].forEach(key => {
|
||||
if (mail.headers && mail.headers.has(key)) {
|
||||
mail[key.replace(/-([a-z])/g, (m, c) => c.toUpperCase())] = mail.headers.get(key);
|
||||
}
|
||||
});
|
||||
|
||||
if (keepCidLinks) {
|
||||
return callback(null, mail);
|
||||
}
|
||||
parser.updateImageLinks(
|
||||
(attachment, done) => done(false, 'data:' + attachment.contentType + ';base64,' + attachment.content.toString('base64')),
|
||||
(err, html) => {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
mail.html = html;
|
||||
|
||||
callback(null, mail);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
if (typeof input === 'string') {
|
||||
parser.end(Buffer.from(input));
|
||||
} else if (Buffer.isBuffer(input)) {
|
||||
parser.end(input);
|
||||
} else {
|
||||
input
|
||||
.once('error', err => {
|
||||
input.destroy();
|
||||
parser.destroy();
|
||||
callback(err);
|
||||
})
|
||||
.pipe(parser);
|
||||
}
|
||||
|
||||
return promise;
|
||||
};
|
||||
|
||||
function callbackPromise(resolve, reject) {
|
||||
return function (...args) {
|
||||
let err = args.shift();
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve(...args);
|
||||
}
|
||||
};
|
||||
}
|
||||
28
test/imaps/node_modules/mailparser/lib/stream-hash.js
generated
vendored
Normal file
28
test/imaps/node_modules/mailparser/lib/stream-hash.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
|
||||
const crypto = require('crypto');
|
||||
const Transform = require('stream').Transform;
|
||||
|
||||
class StreamHash extends Transform {
|
||||
constructor(attachment, algo) {
|
||||
super();
|
||||
this.attachment = attachment;
|
||||
this.algo = (algo || 'md5').toLowerCase();
|
||||
this.hash = crypto.createHash(algo);
|
||||
this.byteCount = 0;
|
||||
}
|
||||
|
||||
_transform(chunk, encoding, done) {
|
||||
this.hash.update(chunk);
|
||||
this.byteCount += chunk.length;
|
||||
done(null, chunk);
|
||||
}
|
||||
|
||||
_flush(done) {
|
||||
this.attachment.checksum = this.hash.digest('hex');
|
||||
this.attachment.size = this.byteCount;
|
||||
done();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = StreamHash;
|
||||
48
test/imaps/node_modules/mailparser/package.json
generated
vendored
Normal file
48
test/imaps/node_modules/mailparser/package.json
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"name": "mailparser",
|
||||
"version": "3.6.5",
|
||||
"description": "Parse e-mails",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "grunt"
|
||||
},
|
||||
"author": "Andris Reinman",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Peter Salomonsen",
|
||||
"email": "petersalomonsen@runbox.com",
|
||||
"url": "https://github.com/petersalomonsen"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"encoding-japanese": "2.0.0",
|
||||
"he": "1.2.0",
|
||||
"html-to-text": "9.0.5",
|
||||
"iconv-lite": "0.6.3",
|
||||
"libmime": "5.2.1",
|
||||
"linkify-it": "4.0.1",
|
||||
"mailsplit": "5.4.0",
|
||||
"nodemailer": "6.9.3",
|
||||
"tlds": "1.240.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ajv": "8.12.0",
|
||||
"eslint": "8.44.0",
|
||||
"eslint-config-nodemailer": "1.2.0",
|
||||
"eslint-config-prettier": "8.8.0",
|
||||
"grunt": "1.6.1",
|
||||
"grunt-cli": "1.4.3",
|
||||
"grunt-contrib-nodeunit": "5.0.0",
|
||||
"grunt-eslint": "24.2.0",
|
||||
"iconv": "3.0.1",
|
||||
"random-message": "1.1.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/nodemailer/mailparser.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/nodemailer/mailparser/issues"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user