Skip to content

bitdivine/node-imap-promise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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));

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published