Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move the node-imap configuration to the configuration file #47

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,20 @@ function MailListener(options) {
this.attachmentOptions = options.attachmentOptions || {};
this.attachments = options.attachments || false;
this.attachmentOptions.directory = (this.attachmentOptions.directory ? this.attachmentOptions.directory : '');
this.imap = new Imap({
xoauth2: options.xoauth2,
user: options.username,
password: options.password,
host: options.host,
port: options.port,
tls: options.tls,
tlsOptions: options.tlsOptions || {}
});

if (!options.imap) {
options.imap = {
xoauth2: options.xoauth2,
user: options.username,
password: options.password,
host: options.host,
port: options.port,
tls: options.tls,
tlsOptions: options.tlsOptions || {}
};
}

this.imap = new Imap(options.imap);
this.imap.once('ready', imapReady.bind(this));
this.imap.once('close', imapClose.bind(this));
this.imap.on('error', imapError.bind(this));
Expand Down
14 changes: 8 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ JavaScript Code:
var MailListener = require("mail-listener2");

var mailListener = new MailListener({
username: "imap-username",
password: "imap-password",
host: "imap-host",
port: 993, // imap port
tls: true,
tlsOptions: { rejectUnauthorized: false },
imap: { // please refer to the node-imap documentation for more details on configuration
user: "imap-username",
password: "imap-password",
host: "imap-host",
port: 993, // imap port
tls: true,
tlsOptions: { rejectUnauthorized: false }
},
mailbox: "INBOX", // mailbox to monitor
searchFilter: ["UNSEEN", "FLAGGED"], // the search filter being used after an IDLE notification has been retrieved
markSeen: true, // all fetched email willbe marked as seen and not fetched next time
Expand Down
14 changes: 8 additions & 6 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
var MailListener = require("./");

var mailListener = new MailListener({
username: "xxxx",
password: "xxx",
host: "imap.gmail.com",
port: 993,
tls: true,
tlsOptions: { rejectUnauthorized: false },
imap: {
user: "xxxx",
password: "xxx",
host: "imap.gmail.com",
port: 993,
tls: true,
tlsOptions: { rejectUnauthorized: false }
},
mailbox: "INBOX",
markSeen: true,
fetchUnreadOnStart: true,
Expand Down