Issue with imap node

583 views
Skip to first unread message

bad...@gmail.com

unread,
Nov 24, 2013, 4:17:35 AM11/24/13
to node...@googlegroups.com
Hi,

I'm having a problem with the imap node. I set up emailkeys.js and, when using the email node, I can successfully send messages from the appropriate account. However, I don't get any response from the imap node upon receiving a new mail. Maybe I'm missing something. At the moment, my flow is as simple as imap connected to a debug node - to no avail. Any other suggestions?

Boris

Dave C-J

unread,
Nov 24, 2013, 7:59:08 AM11/24/13
to node...@googlegroups.com
Hi Boris,

the current behaviour is that it only checks for email every 300 secs by default and will only grab the latest (one) email it finds... and then only pass it on if it is different from the last time it checked...  so right now it will take at 5 mins (unless you change timeout) before it will send anything... and then only once unless something new arrives (after the 5 mins).

It should print something like
24 Nov 12:46:03 - [log] [imap:8870b2fd.3ae598] Subj: apps
in the console log if it finds something.

If it's failing to connect it should also be logging error messages in the node console.

I will change it to check right away on startup - so no-one has to wait.


bad...@gmail.com

unread,
Nov 24, 2013, 2:24:06 PM11/24/13
to node...@googlegroups.com
[sorry - accidentally used direct mail: past traffic pasted in after my post]

In the meantime I downloaded the latest 61-imap.js and put a couple of util.log lines in to see what of the code is being executed.

I can confirm that every 30 seconds it goes through

 this.on("input", function(msg) {

        util.log("[opening box]");

        openInbox(function(err, mailbox) {

(around line 60)

if (err) node.log("error : "+err);

            util.log("[fetching]");

                imap.seq.fetch(mailbox.messages.total + ':*', { struct: false },


however, the "[fetching]" message is never seen.

Within function openInbox(cb), I added tracing code

function openInbox(cb) {

    util.log("[openInbox called]");

    imap.connect(function(err) {

        util.log("[openInbox pre-error message]");

        if (err) util.log("[imap] : error : "+err);

        util.log("[openInbox pre-opening]");

        imap.openBox('INBOX', true, cb);

    });

    util.log("[openInbox exited]");

}

of which I get "called" and "excited", the other two messages are never seen.

Does this help or is there further diagnostics I could do?


----------------------------------------------
Hi Boris,

did you get the latest version I pushed to github node-red ?
(either way) - try adding a line to the openInbox function (about line 37) in the 61-imap.js file to make it read

        if (err) util.log("[imap] : error : "+err);
        console.log("[imap]: ok : connected to server");
        imap.openBox('INBOX', true, cb);

ie add the middle console.out line - that will tell us if it connects to the server ok
also around line 66 (in latest version) check the line
      node.log('Read message no. ' + msg.seqno);
should not be commented out (it was in old version)
likewise that will tell us if it reads anything back once logged in.





On 24 November 2013 15:29, Boris wrote:
Hi Dave,

Lack of console messages - that's a start. All I see in regard to the imap node is [log] [imap:WorkMail] repeat = 30000 after starting the flow and that's the end of it. I tried different times between email checks, but that didn't help. So to conclude, I don't even get a failure (or success) to connect. All of this is happening on a Raspberry Pi with the latest Raspian, if that helps. As a workaround I could script something in Python that dumps the number of unread emails into a file, but that's far from Node-RED elegance...

Boris

Dave C-J

unread,
Nov 26, 2013, 3:03:06 PM11/26/13
to node...@googlegroups.com

Turns out the underlying imap npm updated their API and broke backwards compatibility... :-(

I have opened Issue #96 on main Node-RED Github Repo to track.

Fix posted - but will need underlying npm updated to 0.8.x
npm install --force imap

chris mobberley

unread,
Nov 28, 2013, 5:00:58 PM11/28/13
to node...@googlegroups.com
I dont know about anyone else but im still having issues with what is being fetched.

If I set up a tweet -> email then an imap -> debug with the imap set to 30 seconds on first deploy I will get all of the emails but then after messing around with some other nodes and re-deploying I get nothing. Thats fine but if I send a tweet which produces an email as my first flow states, the imap should then check after 30 seconds and push the info to the debug window which it doesnt seem to do.

I get all of this:

28 Nov 21:55:55 - [log] [imap:4e1739d8.b1e8c8] message: #2
28 Nov 21:55:55 - [log] [imap:4e1739d8.b1e8c8] done fetching message

in the console but its not actually displaying the fetched message.

Dave C-J

unread,
Nov 29, 2013, 2:16:29 PM11/29/13
to node...@googlegroups.com
Hi Chris,

as usual it's all a matter of perception :-)... right now it doesn't send duplicate messages. And the old message was being persisted over a re-deploy (but not a re-start of course). So on redeploy it checks for new messages and if it's the same (where same = a stringification of the whole message object (from,subject,payload)) then it doesn't send on...

I have just tweaked it so that now that a) in the console it tells you if it or didn't send something on, and b) made it not survive a redeploy - so you should get a new message every redeploy... (even if it is then a duplicate)

I'm not sure that is best behaviour for emails... but happy to have the debate and try both ways. 


--
http://nodered.org
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
regards

Dave Conway-Jones

Reply all
Reply to author
Forward
0 new messages