Use node-imap to retrieve emails
Here is a module retrieve_email.js
which connects to my gmail account and download the UNSEEN
emails after a date. The code is pretty much copied from the example of the [imap
module]1.
const Imap = require('imap');
const inspect = require('util').inspect;
const simpleParser = require('mailparser').simpleParser;
const imap = new Imap({
user: 'mygmail@gmail.com',
password: 'mypassword',
host: 'imap.gmail.com',
port: 993,
tls: true
});
function openInbox(callback) {
imap.openBox('INBOX', true, callback);
};
async function parse_email(body) {
let parsed = simpleParser(body);
...............
};
module.exports = function() {
imap.once('ready', function() {
openInbox(function(err, box) {
if (error) throw err;
imap.search(['UNSEEN', ['SINCE', 'May 20, 2018']], function(err, results){
if (err) throw err;
var f = imap.fetch(results, {bodies: ''});
f.on('message', function(msg, seqno) {
console.log('Message #%d', seqno);
var prefix = '(#' + seqno + ') ';
msg.on('body', function(stream, info) {
if (info.which === 'TEXT')
console.log(prefix + 'Body [%s] found, %d total bytes', inspect(info.which), info.size);
var buffer = '', count = 0;
stream.on('data', function(chunk) {
count += chunk.length;
buffer += chunk.toString('utf8');
parse_email(buffer);
if (info.which === 'TEXT')
console.log(prefix + 'Body [%s] (%d/%d)', inspect(info.which), count, info.size);
});
stream.once('end', function() {
if (info.which !== 'TEXT')
console.log(prefix + 'Parsed header: %s', inspect(Imap.parseHeader(buffer)));
else
console.log(prefix + 'Body [%s] Finished', inspect(info.which));
});
});
msg.once('attributes', function(attrs) {
console.log(prefix + 'Attributes: %s', inspect(attrs, false, 8));
});
msg.once('end', function() {
console.log(prefix + 'Finished');
});
});
f.once('error', function(err) {
console.log('Fetch error: ' + err);
});
f.once('end', function() {
console.log('Done fetching all messages');
imap.end();
});
});
});
});
imap.once('error', function(err) {
console.log(err);
});
imap.once('end', function() {
console.log('Connection ended');
});
imap.connect();
};
When the module is called in index.js
, I can see in debug that code is scanned from top to the bottom and the last line of code scanned is imap.connect()
and then back to the next line in index.js
, with no connection to the gmail account and no action of retrieving the emails. What is wrong with the code above?
UPDATED: status after socket.connect()
in debug:
node.js imap node-imap
|
show 1 more comment
Here is a module retrieve_email.js
which connects to my gmail account and download the UNSEEN
emails after a date. The code is pretty much copied from the example of the [imap
module]1.
const Imap = require('imap');
const inspect = require('util').inspect;
const simpleParser = require('mailparser').simpleParser;
const imap = new Imap({
user: 'mygmail@gmail.com',
password: 'mypassword',
host: 'imap.gmail.com',
port: 993,
tls: true
});
function openInbox(callback) {
imap.openBox('INBOX', true, callback);
};
async function parse_email(body) {
let parsed = simpleParser(body);
...............
};
module.exports = function() {
imap.once('ready', function() {
openInbox(function(err, box) {
if (error) throw err;
imap.search(['UNSEEN', ['SINCE', 'May 20, 2018']], function(err, results){
if (err) throw err;
var f = imap.fetch(results, {bodies: ''});
f.on('message', function(msg, seqno) {
console.log('Message #%d', seqno);
var prefix = '(#' + seqno + ') ';
msg.on('body', function(stream, info) {
if (info.which === 'TEXT')
console.log(prefix + 'Body [%s] found, %d total bytes', inspect(info.which), info.size);
var buffer = '', count = 0;
stream.on('data', function(chunk) {
count += chunk.length;
buffer += chunk.toString('utf8');
parse_email(buffer);
if (info.which === 'TEXT')
console.log(prefix + 'Body [%s] (%d/%d)', inspect(info.which), count, info.size);
});
stream.once('end', function() {
if (info.which !== 'TEXT')
console.log(prefix + 'Parsed header: %s', inspect(Imap.parseHeader(buffer)));
else
console.log(prefix + 'Body [%s] Finished', inspect(info.which));
});
});
msg.once('attributes', function(attrs) {
console.log(prefix + 'Attributes: %s', inspect(attrs, false, 8));
});
msg.once('end', function() {
console.log(prefix + 'Finished');
});
});
f.once('error', function(err) {
console.log('Fetch error: ' + err);
});
f.once('end', function() {
console.log('Done fetching all messages');
imap.end();
});
});
});
});
imap.once('error', function(err) {
console.log(err);
});
imap.once('end', function() {
console.log('Connection ended');
});
imap.connect();
};
When the module is called in index.js
, I can see in debug that code is scanned from top to the bottom and the last line of code scanned is imap.connect()
and then back to the next line in index.js
, with no connection to the gmail account and no action of retrieving the emails. What is wrong with the code above?
UPDATED: status after socket.connect()
in debug:
node.js imap node-imap
I don't know that library but i just made a functions to send emails with Gmail using Nodemailer and i am using Oauth to authenticate, the other option was to allow unsecured connection. I don't see anywhere you are using Oauth so did you authorised unsecured app connection to Gmail?
– Simon Cadieux
Dec 31 '18 at 21:59
Simon Cadieux
, there are signin information inimap
definition. Nodemailer can't be used to retrieve imap emails as far as I understand.
– user938363
Jan 2 at 3:49
1
Nothing seems wrong with the code, so you need to debug. Is it able to connect at all, or do you have a packet filter that leaves the connection attempt hanging for minutes? And so on. Look for that sort of mishap. tcpdump or wireshark might be handy.
– arnt
Jan 4 at 15:22
Could you add the code fromindex.js
that uses it?
– Styx
Jan 4 at 18:23
arnt
,Styx
, I moved all theimap
code intoindex.js
and went through them many times in debug. I could see the value of theimap
was passed into the imap.connect(). ButopenInbox
was never called and executed. There is no error throw out. I don't quite understand howimap
module works. But it seems to me that the email retrieving (openInbox) was never happened
– user938363
Jan 6 at 18:08
|
show 1 more comment
Here is a module retrieve_email.js
which connects to my gmail account and download the UNSEEN
emails after a date. The code is pretty much copied from the example of the [imap
module]1.
const Imap = require('imap');
const inspect = require('util').inspect;
const simpleParser = require('mailparser').simpleParser;
const imap = new Imap({
user: 'mygmail@gmail.com',
password: 'mypassword',
host: 'imap.gmail.com',
port: 993,
tls: true
});
function openInbox(callback) {
imap.openBox('INBOX', true, callback);
};
async function parse_email(body) {
let parsed = simpleParser(body);
...............
};
module.exports = function() {
imap.once('ready', function() {
openInbox(function(err, box) {
if (error) throw err;
imap.search(['UNSEEN', ['SINCE', 'May 20, 2018']], function(err, results){
if (err) throw err;
var f = imap.fetch(results, {bodies: ''});
f.on('message', function(msg, seqno) {
console.log('Message #%d', seqno);
var prefix = '(#' + seqno + ') ';
msg.on('body', function(stream, info) {
if (info.which === 'TEXT')
console.log(prefix + 'Body [%s] found, %d total bytes', inspect(info.which), info.size);
var buffer = '', count = 0;
stream.on('data', function(chunk) {
count += chunk.length;
buffer += chunk.toString('utf8');
parse_email(buffer);
if (info.which === 'TEXT')
console.log(prefix + 'Body [%s] (%d/%d)', inspect(info.which), count, info.size);
});
stream.once('end', function() {
if (info.which !== 'TEXT')
console.log(prefix + 'Parsed header: %s', inspect(Imap.parseHeader(buffer)));
else
console.log(prefix + 'Body [%s] Finished', inspect(info.which));
});
});
msg.once('attributes', function(attrs) {
console.log(prefix + 'Attributes: %s', inspect(attrs, false, 8));
});
msg.once('end', function() {
console.log(prefix + 'Finished');
});
});
f.once('error', function(err) {
console.log('Fetch error: ' + err);
});
f.once('end', function() {
console.log('Done fetching all messages');
imap.end();
});
});
});
});
imap.once('error', function(err) {
console.log(err);
});
imap.once('end', function() {
console.log('Connection ended');
});
imap.connect();
};
When the module is called in index.js
, I can see in debug that code is scanned from top to the bottom and the last line of code scanned is imap.connect()
and then back to the next line in index.js
, with no connection to the gmail account and no action of retrieving the emails. What is wrong with the code above?
UPDATED: status after socket.connect()
in debug:
node.js imap node-imap
Here is a module retrieve_email.js
which connects to my gmail account and download the UNSEEN
emails after a date. The code is pretty much copied from the example of the [imap
module]1.
const Imap = require('imap');
const inspect = require('util').inspect;
const simpleParser = require('mailparser').simpleParser;
const imap = new Imap({
user: 'mygmail@gmail.com',
password: 'mypassword',
host: 'imap.gmail.com',
port: 993,
tls: true
});
function openInbox(callback) {
imap.openBox('INBOX', true, callback);
};
async function parse_email(body) {
let parsed = simpleParser(body);
...............
};
module.exports = function() {
imap.once('ready', function() {
openInbox(function(err, box) {
if (error) throw err;
imap.search(['UNSEEN', ['SINCE', 'May 20, 2018']], function(err, results){
if (err) throw err;
var f = imap.fetch(results, {bodies: ''});
f.on('message', function(msg, seqno) {
console.log('Message #%d', seqno);
var prefix = '(#' + seqno + ') ';
msg.on('body', function(stream, info) {
if (info.which === 'TEXT')
console.log(prefix + 'Body [%s] found, %d total bytes', inspect(info.which), info.size);
var buffer = '', count = 0;
stream.on('data', function(chunk) {
count += chunk.length;
buffer += chunk.toString('utf8');
parse_email(buffer);
if (info.which === 'TEXT')
console.log(prefix + 'Body [%s] (%d/%d)', inspect(info.which), count, info.size);
});
stream.once('end', function() {
if (info.which !== 'TEXT')
console.log(prefix + 'Parsed header: %s', inspect(Imap.parseHeader(buffer)));
else
console.log(prefix + 'Body [%s] Finished', inspect(info.which));
});
});
msg.once('attributes', function(attrs) {
console.log(prefix + 'Attributes: %s', inspect(attrs, false, 8));
});
msg.once('end', function() {
console.log(prefix + 'Finished');
});
});
f.once('error', function(err) {
console.log('Fetch error: ' + err);
});
f.once('end', function() {
console.log('Done fetching all messages');
imap.end();
});
});
});
});
imap.once('error', function(err) {
console.log(err);
});
imap.once('end', function() {
console.log('Connection ended');
});
imap.connect();
};
When the module is called in index.js
, I can see in debug that code is scanned from top to the bottom and the last line of code scanned is imap.connect()
and then back to the next line in index.js
, with no connection to the gmail account and no action of retrieving the emails. What is wrong with the code above?
UPDATED: status after socket.connect()
in debug:
node.js imap node-imap
node.js imap node-imap
edited Jan 7 at 5:12
user938363
asked Dec 29 '18 at 7:07
user938363user938363
2,5531465143
2,5531465143
I don't know that library but i just made a functions to send emails with Gmail using Nodemailer and i am using Oauth to authenticate, the other option was to allow unsecured connection. I don't see anywhere you are using Oauth so did you authorised unsecured app connection to Gmail?
– Simon Cadieux
Dec 31 '18 at 21:59
Simon Cadieux
, there are signin information inimap
definition. Nodemailer can't be used to retrieve imap emails as far as I understand.
– user938363
Jan 2 at 3:49
1
Nothing seems wrong with the code, so you need to debug. Is it able to connect at all, or do you have a packet filter that leaves the connection attempt hanging for minutes? And so on. Look for that sort of mishap. tcpdump or wireshark might be handy.
– arnt
Jan 4 at 15:22
Could you add the code fromindex.js
that uses it?
– Styx
Jan 4 at 18:23
arnt
,Styx
, I moved all theimap
code intoindex.js
and went through them many times in debug. I could see the value of theimap
was passed into the imap.connect(). ButopenInbox
was never called and executed. There is no error throw out. I don't quite understand howimap
module works. But it seems to me that the email retrieving (openInbox) was never happened
– user938363
Jan 6 at 18:08
|
show 1 more comment
I don't know that library but i just made a functions to send emails with Gmail using Nodemailer and i am using Oauth to authenticate, the other option was to allow unsecured connection. I don't see anywhere you are using Oauth so did you authorised unsecured app connection to Gmail?
– Simon Cadieux
Dec 31 '18 at 21:59
Simon Cadieux
, there are signin information inimap
definition. Nodemailer can't be used to retrieve imap emails as far as I understand.
– user938363
Jan 2 at 3:49
1
Nothing seems wrong with the code, so you need to debug. Is it able to connect at all, or do you have a packet filter that leaves the connection attempt hanging for minutes? And so on. Look for that sort of mishap. tcpdump or wireshark might be handy.
– arnt
Jan 4 at 15:22
Could you add the code fromindex.js
that uses it?
– Styx
Jan 4 at 18:23
arnt
,Styx
, I moved all theimap
code intoindex.js
and went through them many times in debug. I could see the value of theimap
was passed into the imap.connect(). ButopenInbox
was never called and executed. There is no error throw out. I don't quite understand howimap
module works. But it seems to me that the email retrieving (openInbox) was never happened
– user938363
Jan 6 at 18:08
I don't know that library but i just made a functions to send emails with Gmail using Nodemailer and i am using Oauth to authenticate, the other option was to allow unsecured connection. I don't see anywhere you are using Oauth so did you authorised unsecured app connection to Gmail?
– Simon Cadieux
Dec 31 '18 at 21:59
I don't know that library but i just made a functions to send emails with Gmail using Nodemailer and i am using Oauth to authenticate, the other option was to allow unsecured connection. I don't see anywhere you are using Oauth so did you authorised unsecured app connection to Gmail?
– Simon Cadieux
Dec 31 '18 at 21:59
Simon Cadieux
, there are signin information in imap
definition. Nodemailer can't be used to retrieve imap emails as far as I understand.– user938363
Jan 2 at 3:49
Simon Cadieux
, there are signin information in imap
definition. Nodemailer can't be used to retrieve imap emails as far as I understand.– user938363
Jan 2 at 3:49
1
1
Nothing seems wrong with the code, so you need to debug. Is it able to connect at all, or do you have a packet filter that leaves the connection attempt hanging for minutes? And so on. Look for that sort of mishap. tcpdump or wireshark might be handy.
– arnt
Jan 4 at 15:22
Nothing seems wrong with the code, so you need to debug. Is it able to connect at all, or do you have a packet filter that leaves the connection attempt hanging for minutes? And so on. Look for that sort of mishap. tcpdump or wireshark might be handy.
– arnt
Jan 4 at 15:22
Could you add the code from
index.js
that uses it?– Styx
Jan 4 at 18:23
Could you add the code from
index.js
that uses it?– Styx
Jan 4 at 18:23
arnt
, Styx
, I moved all the imap
code into index.js
and went through them many times in debug. I could see the value of the imap
was passed into the imap.connect(). But openInbox
was never called and executed. There is no error throw out. I don't quite understand how imap
module works. But it seems to me that the email retrieving (openInbox) was never happened– user938363
Jan 6 at 18:08
arnt
, Styx
, I moved all the imap
code into index.js
and went through them many times in debug. I could see the value of the imap
was passed into the imap.connect(). But openInbox
was never called and executed. There is no error throw out. I don't quite understand how imap
module works. But it seems to me that the email retrieving (openInbox) was never happened– user938363
Jan 6 at 18:08
|
show 1 more comment
2 Answers
2
active
oldest
votes
Have a look at this, this is the Gmail API reference from Google. On that page there is an example of how to connect to it using Node.js.
https://developers.google.com/gmail/api/quickstart/nodejs
And here is an example from the same docs that show you how to search and retrieve message list using the q parameter:
https://developers.google.com/gmail/api/v1/reference/users/messages/list
P.S. In my comment i was just asking you if you were sure that you did all the other configuration stuff needed to access your Gmail account by code, meaning creating the app, authorizing OAuth or in what seemed to be your case authorizing less secure application access, just have a look at the links you might find that you are missing something.
And do you really need to use IMAP package ???
Yes, I need to use a solution which is not tied up with a specific webmail provider. That's why I have chose the node imap module. When there is a new webmail provider, what I need to do is to provide new information in theimap
definition and I can retrieve emails from another webmail provider. Thank you anyway!
– user938363
Jan 2 at 19:04
add a comment |
The problem found was with Avast mail shield as middle man intercepting the IMAP traffic and causes the HTTPS fails. Also the IDE debugger stops at somewhere to keep the connecting active but not ready. Here is the detail of the solution.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53967482%2fuse-node-imap-to-retrieve-emails%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Have a look at this, this is the Gmail API reference from Google. On that page there is an example of how to connect to it using Node.js.
https://developers.google.com/gmail/api/quickstart/nodejs
And here is an example from the same docs that show you how to search and retrieve message list using the q parameter:
https://developers.google.com/gmail/api/v1/reference/users/messages/list
P.S. In my comment i was just asking you if you were sure that you did all the other configuration stuff needed to access your Gmail account by code, meaning creating the app, authorizing OAuth or in what seemed to be your case authorizing less secure application access, just have a look at the links you might find that you are missing something.
And do you really need to use IMAP package ???
Yes, I need to use a solution which is not tied up with a specific webmail provider. That's why I have chose the node imap module. When there is a new webmail provider, what I need to do is to provide new information in theimap
definition and I can retrieve emails from another webmail provider. Thank you anyway!
– user938363
Jan 2 at 19:04
add a comment |
Have a look at this, this is the Gmail API reference from Google. On that page there is an example of how to connect to it using Node.js.
https://developers.google.com/gmail/api/quickstart/nodejs
And here is an example from the same docs that show you how to search and retrieve message list using the q parameter:
https://developers.google.com/gmail/api/v1/reference/users/messages/list
P.S. In my comment i was just asking you if you were sure that you did all the other configuration stuff needed to access your Gmail account by code, meaning creating the app, authorizing OAuth or in what seemed to be your case authorizing less secure application access, just have a look at the links you might find that you are missing something.
And do you really need to use IMAP package ???
Yes, I need to use a solution which is not tied up with a specific webmail provider. That's why I have chose the node imap module. When there is a new webmail provider, what I need to do is to provide new information in theimap
definition and I can retrieve emails from another webmail provider. Thank you anyway!
– user938363
Jan 2 at 19:04
add a comment |
Have a look at this, this is the Gmail API reference from Google. On that page there is an example of how to connect to it using Node.js.
https://developers.google.com/gmail/api/quickstart/nodejs
And here is an example from the same docs that show you how to search and retrieve message list using the q parameter:
https://developers.google.com/gmail/api/v1/reference/users/messages/list
P.S. In my comment i was just asking you if you were sure that you did all the other configuration stuff needed to access your Gmail account by code, meaning creating the app, authorizing OAuth or in what seemed to be your case authorizing less secure application access, just have a look at the links you might find that you are missing something.
And do you really need to use IMAP package ???
Have a look at this, this is the Gmail API reference from Google. On that page there is an example of how to connect to it using Node.js.
https://developers.google.com/gmail/api/quickstart/nodejs
And here is an example from the same docs that show you how to search and retrieve message list using the q parameter:
https://developers.google.com/gmail/api/v1/reference/users/messages/list
P.S. In my comment i was just asking you if you were sure that you did all the other configuration stuff needed to access your Gmail account by code, meaning creating the app, authorizing OAuth or in what seemed to be your case authorizing less secure application access, just have a look at the links you might find that you are missing something.
And do you really need to use IMAP package ???
answered Jan 2 at 14:32


Simon CadieuxSimon Cadieux
20410
20410
Yes, I need to use a solution which is not tied up with a specific webmail provider. That's why I have chose the node imap module. When there is a new webmail provider, what I need to do is to provide new information in theimap
definition and I can retrieve emails from another webmail provider. Thank you anyway!
– user938363
Jan 2 at 19:04
add a comment |
Yes, I need to use a solution which is not tied up with a specific webmail provider. That's why I have chose the node imap module. When there is a new webmail provider, what I need to do is to provide new information in theimap
definition and I can retrieve emails from another webmail provider. Thank you anyway!
– user938363
Jan 2 at 19:04
Yes, I need to use a solution which is not tied up with a specific webmail provider. That's why I have chose the node imap module. When there is a new webmail provider, what I need to do is to provide new information in the
imap
definition and I can retrieve emails from another webmail provider. Thank you anyway!– user938363
Jan 2 at 19:04
Yes, I need to use a solution which is not tied up with a specific webmail provider. That's why I have chose the node imap module. When there is a new webmail provider, what I need to do is to provide new information in the
imap
definition and I can retrieve emails from another webmail provider. Thank you anyway!– user938363
Jan 2 at 19:04
add a comment |
The problem found was with Avast mail shield as middle man intercepting the IMAP traffic and causes the HTTPS fails. Also the IDE debugger stops at somewhere to keep the connecting active but not ready. Here is the detail of the solution.
add a comment |
The problem found was with Avast mail shield as middle man intercepting the IMAP traffic and causes the HTTPS fails. Also the IDE debugger stops at somewhere to keep the connecting active but not ready. Here is the detail of the solution.
add a comment |
The problem found was with Avast mail shield as middle man intercepting the IMAP traffic and causes the HTTPS fails. Also the IDE debugger stops at somewhere to keep the connecting active but not ready. Here is the detail of the solution.
The problem found was with Avast mail shield as middle man intercepting the IMAP traffic and causes the HTTPS fails. Also the IDE debugger stops at somewhere to keep the connecting active but not ready. Here is the detail of the solution.
answered Jan 9 at 2:13
user938363user938363
2,5531465143
2,5531465143
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53967482%2fuse-node-imap-to-retrieve-emails%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I don't know that library but i just made a functions to send emails with Gmail using Nodemailer and i am using Oauth to authenticate, the other option was to allow unsecured connection. I don't see anywhere you are using Oauth so did you authorised unsecured app connection to Gmail?
– Simon Cadieux
Dec 31 '18 at 21:59
Simon Cadieux
, there are signin information inimap
definition. Nodemailer can't be used to retrieve imap emails as far as I understand.– user938363
Jan 2 at 3:49
1
Nothing seems wrong with the code, so you need to debug. Is it able to connect at all, or do you have a packet filter that leaves the connection attempt hanging for minutes? And so on. Look for that sort of mishap. tcpdump or wireshark might be handy.
– arnt
Jan 4 at 15:22
Could you add the code from
index.js
that uses it?– Styx
Jan 4 at 18:23
arnt
,Styx
, I moved all theimap
code intoindex.js
and went through them many times in debug. I could see the value of theimap
was passed into the imap.connect(). ButopenInbox
was never called and executed. There is no error throw out. I don't quite understand howimap
module works. But it seems to me that the email retrieving (openInbox) was never happened– user938363
Jan 6 at 18:08