-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlistimapboxes.js
executable file
·55 lines (44 loc) · 1020 Bytes
/
listimapboxes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env node
//
//
// List imap "boxes"
//
// Requires "authdata.js" file exporting username and password fields.
//
//
var SERVER = 'imap.gmail.com';
var util = require('util');
var Imap = require('imap');
var authdata = require('authdata');
var imap = new Imap({
user: authdata.username,
password: authdata.password,
host: SERVER,
port: 993,
tls: true,
tlsOptions: { rejectUnauthorized: false }
});
function show(obj) {
return util.inspect(obj, false, Infinity);
}
function die(err) {
process.stderr.write('Uh oh: ' + err + "\n");
process.exit(1);
}
function openInbox(cb) {
// imap.openBox('INBOX', true, cb);
imap.openBox('All Mail', true, cb);
}
imap.once('ready', function() {
imap.getBoxes(function(err,boxes) {
if (err) die(err);
console.log(boxes);
});
});
imap.once('error', function(err) {
process.stderr.write("imap.once error: " + err + "\n");
});
imap.once('end', function() {
process.stderr.write('Connection ended' + "\n");
});
imap.connect();