Enough-Software / enough_mail

IMAP, POP3 and SMTP clients for Dart developers. Contains both low level as well as a high level API.
Mozilla Public License 2.0
100 stars 56 forks source link

IMAP : Authentication failed with MailException(null : null) #204

Open Yowims opened 1 year ago

Yowims commented 1 year ago

Hi,

I'm trying to log in my company mail address using IMAP protocol. I managed to get the server config using the Discover.discover() method, but when I try to use MailClient.connect() method, it throws me an error saying :

Exception has occurred. MailException (MailException: null: null )

My code :

    final config = await Discover.discover("my.name@company.fr");
    final account;
    if (config == null) { // Never reached, but set in case of failure
      account = MailAccount.fromManualSettings(
          "My Name",
          "my.name@company.fr",
          "outlook.office365.com",
          "smtp.office365.com",
          "P@ssword",
          outgoingClientDomain: "company.fr",
          outgoingPort: 587,
          outgoingSocketType: SocketType.starttls);
    } else {
      account = MailAccount.fromDiscoveredSettings(
          "My Name", "my.name@company.fr", r"P@ssword", config,
          outgoingClientDomain: "company.fr");
    }

    final mailClient = MailClient(account, isLogEnabled: true);
    try {
      await mailClient.connect();
      print("mail client connected ! :D");

      final mimeMessage = buildMessage();
      await mailClient.sendMessage(mimeMessage);
    } on Exception catch (e) {
      Navigator.of(context).pop();
      rethrow;
    }

My logs :

flutter: failed to find settings for company.fr: imap: failure pop: failure smtp: failure flutter: A: connecting to server outlook.office365.com:993 - secure: true, timeout: 0:00:10.000000 flutter: S: * OK The Microsoft Exchange IMAP4 service is ready. [UABSADMAUAAxADgAOQBDAEEAMAAwADUAMAAuAEUAVQBSAFAAMQA4ADkALgBQAFIATwBEAC4ATwBVAFQATABPAE8ASwAuAEMATwBNAA==] flutter: C: a0 LOGIN "my.name@company.fr" "(password scrambled)" flutter: S: a0 NO LOGIN failed.