UNPKG

@terranlabs/email-nodes

Version:

Node-RED nodes to send and receive simple emails.

68 lines 5.58 kB
{ "name": "node-pop3", "version": "0.8.0", "description": "POP3 client for node", "main": "./lib/Command.js", "type": "commonjs", "exports": { "import": "./src/Command.mjs", "require": "./lib/Command.js" }, "bin": { "pop": "./bin/pop.js" }, "nyc": { "reporter": [ "text", "lcov" ] }, "repository": { "type": "git", "url": "git+https://github.com/lianxh/node-pop3.git" }, "keywords": [ "pop3", "node", "Promise", "Stream" ], "author": "lianxh", "contributors": [ "Brett Zamir" ], "license": "MIT", "bugs": { "url": "https://github.com/lianxh/node-pop3/issues" }, "homepage": "https://github.com/lianxh/node-pop3#readme", "engines": { "node": ">=6.0.0" }, "dependencies": {}, "devDependencies": { "@babel/cli": "^7.16.8", "@babel/core": "^7.16.7", "@babel/preset-env": "^7.16.8", "@comandeer/babel-plugin-banner": "^5.0.0", "@expo/spawn-async": "^1.5.0", "babel-plugin-add-module-exports": "^1.0.4", "babel-plugin-module-extension": "^0.1.3", "babel-plugin-transform-async-to-promises": "^0.8.18", "chai": "^4.3.4", "eslint": "^8.6.0", "mocha": "^9.1.4", "nyc": "^15.1.0" }, "scripts": { "cli": "node ./bin/pop.js", "lint": "npm run eslint", "eslint": "eslint --ext=mjs,js .", "babel-src": "babel src -d lib --source-maps --out-file-extension .js", "babel-bin": "rm bin/pop.js && babel bin/index.mjs -o bin/pop.js --source-maps --out-file-extension .js && chmod 0755 bin/pop.js", "babel": "npm run babel-src && npm run babel-bin", "mocha": "mocha --require chai/register-expect --exit", "test": "rm -Rf .nyc_output && rm -Rf ./node_modules/.cache && npm run babel && nyc npm run mocha" }, "readme": "# node-pop3\n\npop3 command for node. Supports **Promise** and **stream**.\n\n## CLI\n\ne.g. Test the API about `TOP`\n\n`pop -u example@gmail.com -p pwd -h example.pop.com -m TOP 100 10`\n\nor pass in some or all of the config in a designated config file (JSON or JS):\n\n`pop -c pop.config.js -m TOP 100 10`\n\nFor more detail, please input\n\n`pop --help`\n\n## Usage\n\nIn CommonJS, you can get the `Pop3Command` as follows:\n\n```js\nconst Pop3Command = require('node-pop3');\n```\n\nThe examples below, however, use the [ESM Modules](https://nodejs.org/api/esm.html)\nformat instead (i.e., `import`).\n\n## Example\n\n- Fetch mail by msgNum:\n\n```js\nimport Pop3Command from 'node-pop3';\n\nconst pop3 = new Pop3Command({\n user: 'example@example.com',\n password: 'example',\n host: 'pop3.example.com',\n});\n\nconst msgNum = 1;\n\n(async () => {\n\n await string = pop3.RETR(msgNum);\n // deal with mail string\n await pop3.QUIT();\n\n})();\n```\n\n- List msgNum to uid in Server\n\n```js\nconst list = await pop3.UIDL();\nconsole.dir(list);\n/**\n * [\n * ['1', 'ZC0113-H8wi_YChVab4F0QTbwP4B6i'],\n * ['2', 'ZC0114-3A9gAn8M2Sp1RhVCGTIII6i'],\n * ...\n * ]\n*/\n```\n\n## API\n\n* constructor(options)\n\nparams|optional|comment\n---|---|---\noptions.user|no|String\noptions.password|no|String\noptions.host|no|String\noptions.port|yes|Number. Defaults to `110`\noptions.servername|yes|String. Defaults to `host` value. Same as `servername` for Node TLS option.\noptions.tls|yes|Boolean. Defaults to `false`\noptions.timeout|yes|Number. Defaults to `undefined`\noptions.tlsOptions|yes|Defaults to `{}`\n\n`tlsOptions` takes the options documented for your Node version and\n`tls.connect` function.\n\n* basic\n\nmethod|params|return\n---|---|---\nconnect||`{Promise}` resolve to `undefined`\ncommand|`{String*}` command messages to Server|`{Promise}` resolve to `{Array[String, Stream]}`, which are messages of response and stream of response (if the response has multiple lines) from Server\n\n```js\nconst pop3 = new Pop3Command({ host: 'pop3.example.com' });\n\n(async () => {\n\n await pop3.connect();\n await pop3.command('USER', 'example@example.com');\n await pop3.command('PASS', 'example');\n\n const [info] = await pop3.command('STAT');\n console.log(info); // 100 102400\n\n const [info, stream] = await pop3.command('RETR', 1);\n console.log(info); // 1024 octets\n\n const [info] = await pop3.command('QUIT');\n console.log(info); // Bye\n\n})();\n\n```\n\n* common\n\nmethod|params|return|comment\n---|---|---|---\nUIDL|`{String\\|Number}` msgNum|`{Promise}` resolve to `{Array}` list of responsed|msgNum is optional\nRETR|`{String\\|Number}` msgNum|`{Promise}` resolve to `{String}` of mail stream|\nTOP|`{String\\|Number}` msgNum, `{Number}` n|`{Promise}` resolve to `{String}` message of responsed|n is default to 0\nQUIT||`{Promise}` resolve to `{String}` message of response message|\n\n## ERROR\n\npop3 will throw new Error's with an error message from Server.\nBeyond that, Error may have two properties attached by pop3.\n\nproperty|comment\n---|---\n`err.eventName`|event name comes from `socket.on`. Includes `error`, `close`, `timeout`, `end`, and `bad-server-response`. `command` may also throw `no-socket`.\n`err.command`|which command causes the error. For example, `PASS example`\n\n## To-dos\n\n1. Testing:\n 1. Ensure tests seed (and then delete) messages (e.g., using `emailjs`)\n 1. Set up CI with hidden `pop.config.json` credentials\n 1. Avoid skipping some tests\n1. Edge cases\n 1. After timeout, ensure any stream is ended (so other commands can\n continue)\n 1. Ensure `command` will reject if socket is ended.\n 1. Ensure in fixing the above that can QUIT and reuse same instance\n" }