node package manager

iitg-webmail-notify

iitg-webmail-notify

npm version

A module for getting event based notifications containing new webmail for IITG webmail servers.

Installation

$ npm install iitg-webmail-notify

Usage

### Example

var Webmail = require('iitg-webmail-notify');
....
 
// Store user details in an object 
var userDetails = {
  username : username, // Without @iitg.ernet.in 
  password : password,
  mailServer: mailServer // Among 'teesta', 'disang', 'naambor', 'tamdil', 'dikrong' 
  path: '', // specify relative folder where to save attachments 
            // defaults to folder where this is called from 
  debug: true // for extra output, defaults to false  
};
 
// Create new Webmail object 
webmail = new Webmail(user);
 
// Pass a callback which will be called 
// when a new mail is recevied in user's 
// inbox. mail is an object as described below. 
webmail.on('mail', function(mail) {
  console.log(mail)
  // Can user socket emitter event here 
  // For example: 
  // socket.emit('webmail', mail); 
})
 
// Catch error event. 
webmail.on('error', function(error) {
  console.log(error)
})
...

Data types

  • mail is an object representing the newly received webmail, and has the following properties:
    • from - object - The sender of the mail. Contains two entries.
      • email - string - The email of the sender
      • name - string - The name of the sender
    • to - array - The receivers of the mail. Each entry is an object with email and name, as described above.
    • date - date - The internal server date for the mail.
    • subject - string - The subject of the mail.
    • text - string - Plain text body of the mail.
    • textAsHtml - string - The plaintext body of the message formatted as HTML.
    • attachments - array - Array of objects containing name and path of each attachment.

TODO

  • Attachments
  • Filtering
  • Tests

License

The MIT License (MIT). Please see License File for more information.