npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

imap-riyo

v1.0.16

Published

Email Parsing

Downloads

6

Readme

Install

$ npm install imap-riyo

Introduction

This library is providing a easiest functionality for parsing emails with simple ineterface using imap module. If the authentication will success, you will get a results on 'success' API call based on your configuration.

Please go through the below example:

  var imap = require('imap-riyo');
  var config = {
      username: '[email protected]',
      password: '********',
      host: 'imap.gmail.com',
      debug: 'off',
      mailbox: 'INBOX', 
      searchFilter: ['UNSEEN'],
      mailParserOptions: {streamAttachments: true},
      attachments: true,
      attachmentOptions: { directory: 'attachments',stream:true },
      reCheckMode : false,
      dividerBeforeSignature: '<==================>'
  };

  new imap(config).on('success',function(result){
    console.log(result)
  });

On 'success' API call, you will get a result something like this

{
    "data": [
        {
            "subject": "Hello World",
            "text": " This is a test messages",
            "date": "2018-07-24T06:31:45.000Z",
            "from": [
                {
                    "address": "[email protected]",
                    "name": "Test developer"
                }
            ],
            "to": [
                {
                    "address": "[email protected]",
                    "name": ""
                }
            ],
            "attachment": [
                "Screenshot from 2018-06-06 17-28-05.png",
                "Screenshot from 2018-06-25 18-06-30.png",
                "Screenshot from 2018-06-25 18-33-16.png"
            ]
        }
    ],
    "status": true
}

Others configuration

  var config = {
    username: '[email protected]',
    password: '***********',
    host: 'imap.gmail.com',
    port: 993, // imap port
    tls: true,
    connTimeout: 10000, // Default by node-imap
    authTimeout: 5000, // Default by node-imap,
    debug: 'off', // debuging
    tlsOptions: { rejectUnauthorized: false },
    mailbox: 'INBOX', // mailbox to monitor
    searchFilter: ['UNSEEN'], // the search filter
    mailParserOptions: {streamAttachments: true}, // options to be passed to mailParser lib.
    attachments: true, // searching attachments
    attachmentOptions: { directory: 'attachments',stream:true }, // specify a download directory for attachments, otherwise it will create a directory with the name of 'attachments' in the project directory, if 'attachments:true'
    // to pause for 'fetchingPauseTime' fetching of the email, because it 'hangs' your app
    fetchingPauseThreshold: null, // amount bytes
    fetchingPauseTime: 5000, // ms to pause fetching and process other requests,
    reCheckMode : false, // update mail once again after results found
    dividerBeforeSignature: '<=====================>' // this is the divider, means that discard everything below after this symbol.
  };

Others search criteria

Get unread emails since Jul 21, 2018:

  // using the functions and variables already defined in the first example ..

  searchFilter:[ 'UNSEEN', ['SINCE', 'Jul 21, 2018'] ]

You can set your won custom search criteria in the search filter. Please go through the below reference

  var delay = 24 * 3600 * 1000;
  var previousDay = new Date();
  previousDay.setTime(Date.now() - delay);
  previousDay = previousDay.toISOString(); // 2018-07-20T22:18:40.013Z

  searchFilter:[ 'UNSEEN', ['SINCE', previousDay]]

Attachments

Setting 'attachments: true' means, it will check attachments and will download to the project directory, while parsing emails details, otherwise it will ignore all the attachments. You can also specify for the download directory using the setting of 'attachmentOptions: { directory: 'attachments'}'.