enough_mail
enough_mail copied to clipboard
IMAP : Authentication failed with MailException(null : null)
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("[email protected]");
final account;
if (config == null) { // Never reached, but set in case of failure
account = MailAccount.fromManualSettings(
"My Name",
"[email protected]",
"outlook.office365.com",
"smtp.office365.com",
"P@ssword",
outgoingClientDomain: "company.fr",
outgoingPort: 587,
outgoingSocketType: SocketType.starttls);
} else {
account = MailAccount.fromDiscoveredSettings(
"My Name", "[email protected]", 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 "[email protected]" "(password scrambled)" flutter: S: a0 NO LOGIN failed.