Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

imap-idle-keep-connection

Package Overview
Dependencies
Maintainers
0
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

imap-idle-keep-connection

use node-imap to connect to an imap server. Keep connection alive at all costs and only emit mail event.

  • 0.3.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
70
decreased by-64.29%
Maintainers
0
Weekly downloads
 
Created
Source

ImapIdleKeepConnection

use node-imap to connect to an imap server and handle all errors. Only emit mail event

Usage example:


const ImapIdleKeepConnection = require('imap-idle-keep-connection');

const imapConnection = new ImapIdleKeepConnection({
    user: MailUser,
    password: MailPassword,
    xoauth2: token, //alternative: supply xoauth2 token instead of password. You'll have to obtain the token yourself. 
    host: MailServer,
    port: MailServerPort,
    tls: true, //use TLS or not
    
    //optional log methods. By default errors are logged to console and nothing else:
    log: () => {},
    debug: () => {},
    error: () => {},
    
    // keepalive:
    interval: 10000, //default 10000ms - NOOPs are send & idleInterval is checked,
    idleInterval: 120000, //default 120000ms - interval at which IDLE command is resend
    forceNoop: false //default: false - force use of NOOP keepalice on servers also support IDLE
});

imapConnection.on('mail', (imap, numNewMessages) => {
    console.log('yay, got new mail!');
    //use imap, which is a node-imap instance to maybe receive mail.
});

imapConnection.on('need-authentication', () => {
    console.log('Authentication failed. Won\'t retry. Get new token (maybe, if oauth) and start again.');
    //need to create new object with new credentials in this case!
    imapConnection.endWatch();
});

imapConnection.on('error', error => {
    console.log('Something went horribly wrong...', error);
});

FAQs

Package last updated on 08 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc