Skip to content

Instantly share code, notes, and snippets.

@lperrin
Created March 8, 2013 09:47
Show Gist options
  • Save lperrin/5115382 to your computer and use it in GitHub Desktop.
Save lperrin/5115382 to your computer and use it in GitHub Desktop.
var IMAP = require('imap');
var imap = new IMAP({
user: 'frontapp@gmail.com',
password: 'redcontact',
host: 'imap.gmail.com',
port: 993,
secure: true,
debug: console.log
});
imap.open({inbox: 'INBOX', sent: '[Gmail]/Sent Mail'}, function (err, mailboxes) {
});
var options = {
body: 1,
structure: true,
headers: ['from', 'to', 'subject']
};
imap.fetch(range, options).on('message', function (msg) {
msg.on('data', function (chunk) {
// body data incoming
});
msg.on('end', function () {
// message is fully parsed
});
}).on('end', function (err) {
// no more messages or error happened
});
var query = {
inbox: [['HEADER', 'FROM', 'CONTACT']],
sent: [['HEADER', 'TO', 'CONTACT']]
};
var promise = imap.search(query, options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment