Coder Social home page Coder Social logo

Comments (6)

michaelspiss avatar michaelspiss commented on August 27, 2024

Hi, r'...' tells dart to treat the text as a regular expression. You can escape special characters with a backslash: 'xxxx\$xxxx'. Other than that I cannot see any apparent mistakes.

from imap_client.

bartonhammond avatar bartonhammond commented on August 27, 2024

My understanding is that r is raw string. From https://www.learndartprogramming.com/fundamentals/strings-and-raw-strings-in-dart/
Maybe I'm confused, but I don't think so (at least, at this moment)

Defining raw Strings in Dart
What is a raw strings in Dart: In Dart programming language, raw strings are a type of strings where special characters such as \ do not get special treatment.

Raw strings are useful when you want to define a String that has a lot of special characters.

from imap_client.

michaelspiss avatar michaelspiss commented on August 27, 2024

Wrong language, my bad - you are correct. Your code seems to be equal to the example which has been tested with gmail, so it should be alright...

from imap_client.

bartonhammond avatar bartonhammond commented on August 27, 2024

I created a Google account with userid/password shown below. It still fails. You can try this code

import 'dart:io';

import 'package:imap_client/imap_client.dart';

Future<void> main() async {
  // print log, helpful for debugging
  printImapClientDebugLog();

  var client = ImapClient();
  // connect
  await client.connect('imap.gmail.com', 993, true);
  // authenticate
  final response = await client.authenticate(
      ImapPlainAuth('[email protected]', r'ujbzZ4uhmd'));

  print('reponse ok? ${response == ImapTaggedResponse.ok}');
  if (response != ImapTaggedResponse.ok) {
    exit(1);
  }
  // get folder
  var inbox = await client.getFolder('Inbox');
  // get "BODY" for message 1
  print(await inbox.fetch(['BODY'], messageIds: [1]));
  // get "BODYSTRUCTURE" for message 1
  print(await inbox.fetch(['BODYSTRUCTURE'], messageIds: [1]));
  // close connection
  await client.logout();
}```

Logs:

dart bin/emailTest.dart
[INFO] imap_client: Connecting to imap.gmail.com at port 993 with secure mode on
[INFO] imap_client: S: * OK Gimap ready for requests from 24.183.26.195 j10mb205926323jam

[INFO] imap_client: C: A1 CAPABILITY

[INFO] imap_client: S: * CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 XYZZY SASL-IR AUTH=XOAUTH2 AUTH=PLAIN AUTH=PLAIN-CLIENTTOKEN AUTH=OAUTHBEARER AUTH=XOAUTH
A1 OK Thats all she wrote! j10mb205926323jam

[INFO] imap_client: C: A2 AUTHENTICATE PLAIN

[INFO] imap_client: S: +

[INFO] imap_client: C: AHZpam9wb3Q5NTBAZ21haWwuY29tAHVqYnpaNHVobWQ=

[INFO] imap_client: S: A2 NO [AUTHENTICATIONFAILED] Invalid credentials (Failure)

reponse ok? false

from imap_client.

michaelspiss avatar michaelspiss commented on August 27, 2024

Did you enable imap in gmail's options? Other than that I really cannot see why this shouldn't work

from imap_client.

bartonhammond avatar bartonhammond commented on August 27, 2024

When I went to check the Google Settings, I was prompted with warning that a call from an unsecure app had been blocked because it didn't meet the standards Google has. It asked if the block was correct or if I were the person trying to access the account. Once I replied that I was blocked, it took me through these screens about reducing the security. Sorry I didn't get a picture of the first dialog.

Screen Shot 2020-12-17 at 9 21 21 AM

So I updated
Screen Shot 2020-12-17 at 9 21 55 AM

And now it works:

mailTest]$ dart bin/emailTest.dart 
[INFO] imap_client: Connecting to imap.gmail.com at port 993 with secure mode on
[INFO] imap_client: S: * OK Gimap ready for requests from 24.183.26.195 q187mb93813797ywf

[INFO] imap_client: C: A1 CAPABILITY

[INFO] imap_client: S: * CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 XYZZY SASL-IR AUTH=XOAUTH2 AUTH=PLAIN AUTH=PLAIN-CLIENTTOKEN AUTH=OAUTHBEARER AUTH=XOAUTH
A1 OK Thats all she wrote! q187mb93813797ywf

[INFO] imap_client: C: A2 AUTHENTICATE PLAIN

[INFO] imap_client: S: + 

[INFO] imap_client: C: AHZpam9wb3Q5NTBAZ21haWwuY29tAHVqYnpaNHVobWQ=

[INFO] imap_client: S: * CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 UIDPLUS COMPRESS=DEFLATE ENABLE MOVE CONDSTORE ESEARCH UTF8=ACCEPT LIST-EXTENDED LIST-STATUS LITERAL- SPECIAL-USE APPENDLIMIT=35651584
A2 OK [email protected] authenticated (Success)

from imap_client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.