Created
March 8, 2013 09:47
-
-
Save lperrin/5115382 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var IMAP = require('imap'); | |
var imap = new IMAP({ | |
user: '[email protected]', | |
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