This is a
playground to test code. It runs a full
Node.js environment and already has all of
npm’s 400,000 packages pre-installed, including
email-scraper with all
npm packages installed. Try it out:
email-scraper lists no main file and has no index.js, so it can't be directly required. If this is a mistake, please let us know. It may however contain internal files that you can require manually:
This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.
Turn a mailbox into a read API. Availalble on npmjs.com: https://www.npmjs.com/package/email-scraper
Scrapes e-mail from a specified e-mail server, extracting string results according to specified matching patterns, and sends the output to a configured location.
This is useful, for example, for having billing information written to a database from a service that sends e-mail notification of payment received, but offers no programmatic api for obtaining the data.
Can be used from the command line or programmatically, as described below in the "Usage" section.
enginesfield in the file
./package.jsonfor details on the version.
To use this beyond the default test settings, you will need to:
./conf/mail_servers.conf.jsby following the pattern set by any entry in that file.
retrievewill cause the mail program to run a separate, custom module to retrieve the credentials.
./conf/output_targets.conf.jsby following the pattern set by any entry in that file.
If you have
yarn install email-scraper make instally
or if you want to use
npm install email-scraper make install
Tip: Use the provided alternative:
make instally . This will use the yarn package manager instead of npm. Yarn is typically much, much faster.
If you do not have or want
make install instead of
If not running using the test server, then the mail server and extraction job will need to be configured. See
./conf/README.md for details.
make starttestmailserver. Stop it like this:
Example (running with all defaults, which uses the test mailserver that is bundled with this project; assumes that the test email server is running (see above)):
If using any command line arguments, use the included npm scripts as shown below.
npm run-script run -- --startAt=1
To keep the server listening indefinitely on mailserver 'foo':
npm run-script run -- --mailserver=foo --username=bar --password=bat --keepListening=true
src/index.js shows how to use this package from your NodeJS program. Essentially, you will use the module,
src/scrape_mail.js as your entry point.
Ensure that your code meets lint:
Then run the tests as shown below, ensuring that you see "Test Passed" as the test result.
The pre-requisites are the same as for
For more info on how to set up and use your debugging tools, see:
npm run-script run-debug -- --startAt=1
npm run-script run-debug -- --mailserver=foo --username=bar --password=bat --keepListening=true
Current output options include output to console, write to file (currently includes csv format), or write to database. Use the command line option
--output to select the output type. The default is output to the console.
See the file
conf/output_targets.conf.js for examples of the output options available. That is where you will do any configuration you need for your output. For info on the database structure required for database output, see the file
Port 1110 must be available.
make test debug=true
Configure the test mail server and other settings in
./conf/test.conf.js, according to the relevant information in
Get help on the mail program features like this:
To iterate quickly over successive runs, use the bundled local test email server. To do this, first start the test email server with
make starttestmailserver. Then, do
If you would like to alter the test data that is used by the bundled local test email server, this is done in the file
./test/util/test_messages.js. Modify the two components, the message body list and the message metadata list. To see your change, you will need to restart the test email server:
README.md(new or existing).