Skip to content

Latest commit

 

History

History
34 lines (28 loc) · 1.06 KB

README.md

File metadata and controls

34 lines (28 loc) · 1.06 KB

imap-promise

This is a node IMAP client that uses promises. It is based on node-imap but the resulting code is shorter and easier to understand.

Installation:

npm install imap-promise

Usage:

var IPromise = require('imap-promise');
var myMostPrivateDetails = {user:'[email protected]',password:'fiddle',host:'mail.myhome.com'};
var imap = new IPromise(myMostPrivateDetails);
imap.connectAsync()
.then(function(){console.log('connected');})
.then(function(){return imap.openBoxAsync('INBOX',true);})
.then(function(box){
	// Panda wants his first 3 emails:
	// Emails are numbered.  See: https://github.com/mscdex/node-imap#api
	return imap.getMailAsync('1:3', {
		bodies: 'HEADER.FIELDS (FROM TO SUBJECT DATE)',
		struct: true
	}), function(message){
		// For each e-mail:
		return imap.collectEmailAsync(message);
	});
})
.then(function(messages){
	console.log(JSON.stringify(messages,null,2));
})
.catch(function(error){console.error("Oops:", error.message);})
.then(process.exit.bind(process,0));