chirag04/mail-listener2

gmail blocking access

Closed this issue · 6 comments

Putting my username and password into the test script fails with the message:

{ [Error: Please log in via your web browser: http://support.google.com/mail/accounts/bin/answer.py?answer=78754 (Failure)] textCode: 'ALERT', source: 'authentication' }

Then I received an email from google:

Hi ********, 

We recently blocked a sign-in attempt to your Google Account [********@gmail.com]. 

Sign in attempt details
Date & Time: Tuesday, September 9, 2014 2:30:15 PM UTC 
Location: New York, USA 

If this wasn't you
Please review your Account Activity page at https://security.google.com/settings/security/activity to see if anything looks suspicious. Whoever tried to sign in to your account knows your password; we recommend that you change it right away. 

If this was you
You can switch to an app made by Google such as Gmail to access your account (recommended) or change your settings at https://www.google.com/settings/security/lesssecureapps so that your account is no longer protected by modern security standards. 

To learn more, see https://support.google.com/accounts/answer/6010255. 

Sincerely,
The Google Accounts team

Have you been able to use mail-listener2 with gmail? If so, how do I get around the constraint?

I currently have this working on a Google Apps for Business account but it should work fine for any regular Gmail account as well. Ensure you have IMAP enabled in your Gmail settings. Things like 2-factor authentication may also interfere this this module working.

If you follow the link that you've provided above it'll take you to a flag in gmail which will make this work.

I'm having a similar issue with Google Apps. I get this error like 3 times and then it connects and pulls some emails. However over time it will eventually disconnect and never recover despite my reconnect in the error function. The flag mentioned above is not available for Google Apps accounts. Is there a way to auth with SMTP that is more secure that would be preferable to use?

{"message":"connect ECONNREFUSED","name":"Error","stack":"Error: connect ECONNREFUSED\n    at exports._errnoException (util.js:742:11)\n    at Object.afterConnect [as oncomplete] (net.js:982:19)","code":"ECONNREFUSED"}
var mailListener = new MailListener({
    username: "login",
    password: "password",
    host: "imap.gmail.com",
    port: 993, // imap port
    tls: true,
    tlsOptions: {rejectUnauthorized: true},
    mailbox: "INBOX", // mailbox to monitor
    searchFilter: ["UNSEEN"], // 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
    fetchUnreadOnStart: true, // use it only if you want to get all unread email on lib start. Default is `false`,
    mailParserOptions: {streamAttachments: false}, // options to be passed to mailParser lib.
    attachments: false, // download attachments as they are encountered to the project directory
    attachmentOptions: {directory: "attachments/"} // specify a download directory for attachments
  });

  mailListener.on("server:connected", function () {
    data.log.info("Waiting for email notifications");
  });

  mailListener.on("server:disconnected", function () {
    data.log.info("Email notifications disconnected");
    startListening();
  });

  mailListener.on("error", function (err) {
    data.log.warn(err);
    stopListening();
    startListening();
  });

  mailListener.on("mail", function (mail, seqno, attributes) {

  });

  function stopListening(){
    mailListener.stop();
  }

  function startListening(){
    mailListener.start();
  }

startListening();

@ablankenship10 : did you get the solution

hi, everyone.

I don't know why, but, followed your solution(turn on the less secure & setup the IMAP), this issue didn't be solved. In the end, I tried to use other gmail account with the same setting, everything is all right, unbelievable!!