forked from chirag04/mail-listener2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
40 lines (33 loc) · 830 Bytes
/
test.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
var MailListener = require("./");
var mailListener = new MailListener({
username: "xxxx",
password: "xxx",
host: "imap.gmail.com",
port: 993,
tls: true,
tlsOptions: { rejectUnauthorized: false },
mailbox: "INBOX",
authTimeout: 50000,
connTimeout: 50000,
debug:console.log,
markSeen: true,
fetchUnreadOnStart: true,
attachments: true,
attachmentOptions: { directory: "attachments/" }
});
mailListener.start();
mailListener.on("server:connected", function(){
console.log("imapConnected");
});
mailListener.on("server:disconnected", function(){
console.log("imapDisconnected");
});
mailListener.on("error", function(err){
console.log(err);
});
mailListener.on("mail", function(mail){
console.log(mail);
});
mailListener.on("attachment", function(attachment){
console.log(attachment);
});